#include "compare.h" #include "genprint.h" int main(int argc, char *argv[]) { int i; type_t t; int ntype = NUMTYPES; // nombre de types possibles int n = (argc >= 2) ? atoi(argv[1]) : -1; // n = nombre d'éléments const char *s = (argc >= 3) ? argv[2] : type[INT]; // t = type des éléments for (t = 0; t < ntype; t++) if (!strcmp(s, type[2 * t])) break; // type trouvé ! if (n < 0 || t == ntype) { // erreur printf("\n Usage: %s n [t]", argv[0]); printf("\n Ex.: %s 10 int\n\n", argv[0]); printf(" n = number of random elements\n"); printf(" t = type of elements & fcmp():\n\n"); for (t = 0; t < ntype; t++) { printf(" '%s' ", type[2 * t]); // rule(12 - strlen(type[2 * t]), "."); printf(" %s\n", type[2 * t + 1]); } printf("\n"); exit(1); } unsigned seed = time(NULL) % 1000; srandom(seed); printf("\nseed: %u\n", seed); // pour rejouer la même chose au cas où void *T = malloc(n * size[t]); // tableau initial printf("Tableau avec %i elements de type '%s'\n", n, type[2 * t]); printf("(%s)\n", type[2 * t + 1]); // affichage et création de T[] printf("input array: "); for (i = 0; i < n; i++) { init(t, T, i); print(t, T, i); } printf("\n\n"); return 0; }