forked from menault/TD4_DEV51_Qualite_Algo
je ne sais pas
This commit is contained in:
BIN
exo3/a.out
Executable file
BIN
exo3/a.out
Executable file
Binary file not shown.
72
exo3/algo.c
Normal file
72
exo3/algo.c
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int * tri(int n, int m, int * LETABLEAU){
|
||||||
|
/*JE EN SAIS PAS */
|
||||||
|
int offset=0;
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
for(int j=0; j<m; j++){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv){
|
||||||
|
/*variables*/
|
||||||
|
int n=0;
|
||||||
|
int m=0;
|
||||||
|
int format_count=0;
|
||||||
|
int element_count=0;
|
||||||
|
int element_count_test=0;
|
||||||
|
int count=0;
|
||||||
|
unsigned short int done=0;
|
||||||
|
|
||||||
|
/*tests*/
|
||||||
|
if(argc < 2){
|
||||||
|
printf("USAGE: ./a.out <tableau>\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(argv[1][n]=='['){
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if(n==0){
|
||||||
|
printf("FORMATERROR: Tableau de la forme:[m*[n*element]], où n est la dimension et m le nombre de valeurs\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(argv[1][count]!='\0'){
|
||||||
|
if(argv[1][count]=='['){
|
||||||
|
format_count++;
|
||||||
|
} else if(argv[1][count]==']'){
|
||||||
|
format_count--;
|
||||||
|
if(element_count==0){
|
||||||
|
printf("FORMATERROR: tableau ou sous tableau ne contient aucuns éléments\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
if((element_count_test!=element_count)&&(done==1)&&(format_count==n-1)){
|
||||||
|
printf("FORMATERROR: nombre incohérents d'éléments dans le tableau\n");
|
||||||
|
printf("%d %d\n", element_count, element_count_test);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
element_count_test=0;
|
||||||
|
done=1;
|
||||||
|
} else {
|
||||||
|
if(argv[1][count]!=','){
|
||||||
|
if(done==0){
|
||||||
|
element_count++;
|
||||||
|
} else {
|
||||||
|
element_count_test++;
|
||||||
|
}
|
||||||
|
*(tableau+count) = argv[1][count] - '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(format_count!=0){
|
||||||
|
printf("FORMATERROR: dimensions incohérentes dans le tableau\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
m = element_count;
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user