Ajout des TP
This commit is contained in:
25
BUT1/DEV1.1/CM2_2/EntrainementDS2/SUJET1 /EXO 1/main.c
Normal file
25
BUT1/DEV1.1/CM2_2/EntrainementDS2/SUJET1 /EXO 1/main.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../EXO 1/repetition.h"
|
||||
|
||||
|
||||
int main(int argc,char* argv[]){ /* Ou "char** argv" */
|
||||
int i;
|
||||
long* tab;
|
||||
tab = (long*) malloc(argc*sizeof(long));
|
||||
/* Création d'un tableau de argc - 1 élément (Autrement dit, création d'un tableau du nombre d'éléments donner en argument au programme sans compter le a.out)*/
|
||||
for(i=1;i<argc;i++){
|
||||
tab[i-1] = strtol(argv[i],NULL,10);
|
||||
}
|
||||
|
||||
if(repetition(tab,argc-1)==0){
|
||||
printf("les valeurs sont différentes");
|
||||
}
|
||||
if(repetition(tab,argc-1)==1){
|
||||
printf("les valeurs sont identiques");
|
||||
}
|
||||
free(tab);
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user