init projet

This commit is contained in:
2024-10-06 15:32:20 +02:00
commit d449d4b10a
84 changed files with 13546 additions and 0 deletions

47
tp2/compare.c Normal file
View File

@@ -0,0 +1,47 @@
#include "compare.h"
// tableau des tailles des types (ne pas modifier)
int psize[] = {
2, 1, 5, MAXSTR, 9,
};
// tableau des fonctions de comparaison
fcmp cmp[] = {
fcmp_int, fcmp_char, fcmp_double, fcmp_string, fcmp_pointx,
};
// tableau des types pour l'aide
char *type[] = {
"int", "integers in [0,100[ (default)",
"char", "capital letters in ['A','Z'[",
"double", "real numbers in ]-1.00,+1.00[",
"string", "strings of length at most " xstr(MAXSTR),
"point", "real points of [0,9.9]×[0,9.9] with 'x' like fcmp()",
};
// tableau des tailles des types
int size[] = {
sizeof(int), sizeof(char), sizeof(double), sizeof(string), sizeof(point),
};
int fcmp_int(const void *x, const void *y) {
int a = *((int *)x);
int b = *((int *)y);
return (a < b) ? -1 : (a > b);
}
int fcmp_char(const void *x, const void *y) {
return 0;
}
int fcmp_double(const void *x, const void *y) {
return 0;
}
int fcmp_string(const void *x, const void *y) {
return 0;
}
int fcmp_pointx(const void *p, const void *q) {
return 0;
}