#include #include #include "pascal.h" static void usage (char *com) { fprintf(stderr, "usage : %s n1 n2 .... n_2p-1 n_2p\n", com); exit(1); } int main(int argc, char *argv[]) { triangle pascal; int i; if ((argc % 2) != 1) usage(argv[0]); pascal = triangle_allocate(); triangle_fill (pascal); triangle_display(pascal); printf("\n"); for(i = 1 ; i < argc ; i+=2) { int n = atoi(argv[i]); int p = atoi(argv[i + 1]); printf("binomial(%d,%d)=%d\n", n,p, binomial(pascal,n,p)); } fprintf(stderr, "\n voila l'etat actuel du triangle\n"); triangle_display(pascal); if (triangle_check (pascal)) printf("test passé avec succès\n"); else printf("bug!\n"); triangle_free(pascal); return EXIT_SUCCESS; }