Esempio n. 1
0
int main(int argc, char* argv[])
{
	int ret = 0, val = 0, i = 0;
	int* tab = (int*)malloc(sizeof(int) * 10);
	int* tab_modif = 0;
	
	// On ouvre le fichier
	FILE* file = fopen ("tenvalues.txt", "r");
	
	// Vérifie si il est bien ouvert
	if (!file)
	{
		printf("Impossible d'ouvrir 'tenvalues.txt' !");
		exit(-1);
	}
	
	// On lit chaque ligne
	while (!feof(file))
	{
		ret = fscanf(file, "%d", &val);
		
		// Si fscanf n'est pas valide, ou si on est aux bornes de notre tableau, on s'arrête.
		if (ret != 1 || i == 10)
			break;
		
		// Sinon on assigne la valeur dans notre tableau
		tab[i++] = val;
	}
	
	// On ferme le fichier
	fclose(file);
	
	// On demande la valeur à ajouter
	ret = 0;
	while (ret != 1)
	{
		printf("Valeur a ajouter: ");
		ret = scanf("%d", &val);
		CLRBUF;
	}
	
	// On ajoute la valeur
	tab_modif = add_tab(tab, 10, val);
	
	// On affiche les tableaux
	printf("Original: \n");
	afficheTab(tab, 10);
	
	printf("\nModif: \n");
	afficheTab(tab_modif, 11);
	printf("\n");
	
	// On libère la mémoire
	free(tab);
	free(tab_modif);
	
	return 0;
}
Esempio n. 2
0
int main() {

   float comptes[MAXCOMPTES]={150.5, 160, 12, 1200, 655};
   int autoris[MAXCOMPTES]={1, 0, 1, 1, 0};
   int nbCl = 5;

   afficheTab(comptes, nbCl);

   return 0;
}
Esempio n. 3
0
void cribleEratosthene(int *t, int *n){
	t=tabEratosthene(*n);
	int i, b=1;
    int po=-1;
	while(b==1){
        po=po+1;
		b=0;
		for (i=po+1 ; i<*n ; i++){
			if (t[i]%t[po]==0){
				decalageGauche(t, n, i);
				b=1;
			}
		}
        
	}
	afficheTab(t, *n);
}
Esempio n. 4
0
void afficheAsciiJulia(){
  fractale=2;
  juliaRe = -0.5;
  juliaIm = 0.5;
  afficheTab();
}
Esempio n. 5
0
void afficheAsciiMandel(){
  fractale = 1;
  afficheTab();
}
Esempio n. 6
0
int main() {
    int tab[N] = {3, 2, 4, 8, 5, 7, 6, 1};
    shellSort(tab, N); 
    afficheTab(tab, N);
    return 0;
}