#include // pour affichage #include /* -------------- */ int somme_for(int n) /* -------------- */ { int i; // indice de la boucle int s; // somme // init s = 0; // calcul de la somme for(i=1; i<=n; i++) { s += i; } return s; } /* ------------- */ int somme_do(int n) /* ------------- */ { return 0; } /* ---------------- */ int somme_while(int n) /* ---------------- */ { return 0; } /* --------------- */ int somme_math(int n) /* --------------- */ { return 0; } /* ----------------- */ void test_boucles(void) /* ----------------- */ { int n = 10; int s_for = 0; int s_do = 0; int s_while = 0; int s_math = 0; puts("=== test boucles ==="); s_for = somme_for(n); s_do = somme_do(n); s_while = somme_while(n); s_math = somme_math(n); printf("n = %d\n", n); printf("s_for = %d\n", s_for); printf("s_do_while = %d\n", s_do); printf("s_while = %d\n", s_while); printf("s_math = %d\n", s_math); // ajouter test } /* ------------- */ int is_prime(int n) /* ------------- */ { return 0; } /* ------------------ */ int is_prime_fast(int n) /* ------------------ */ { return 0; } /* --------------- */ int next_prime(int n) /* --------------- */ { return 0; } /* -------------------- */ void display_primes(int n) /* -------------------- */ { } /* --------------- */ void test_prime(void) /* --------------- */ { } /* ------------- */ int fact_rec(int n) /* ------------- */ { return 0; } /* --------- */ int fact(int n) /* --------- */ { return 0; } /* --------------------- */ void test_factorielle(void) /* --------------------- */ { puts("version recursive"); // test des cas particuliers printf("%d! = %d\n", 0, fact_rec(0)); printf("%d! = %d\n", 1, fact_rec(1)); // cas general printf("%d! = %d\n", 5, fact_rec(5)); puts("version non recursive"); // test des cas particuliers printf("%d! = %d\n", 0, fact(0)); printf("%d! = %d\n", 1, fact(1)); // cas general printf("%d! = %d\n", 5, fact_rec(5)); } /* ---------------- */ int cnp(int n, int p) /* ---------------- */ { return 0; } /* -------------------- */ int cnp_fast(int n, int p) /* -------------------- */ { return 0; } /* --------------------- */ int cnp_smart(int n, int p) /* --------------------- */ { return 0; } /* ------------- */ void test_cnp(void) /* ------------- */ { int n, p; n = 3; p = 1; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); puts(""); n = 5; p = 0; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); n = 5; p = 1; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); n = 5; p = 2; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); n = 5; p = 3; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); n = 5; p = 4; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); n = 5; p = 5; printf("cnp(%d, %d) = %d\n", n, p, cnp(n,p)); puts(""); n = 5; p = 0; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 5; p = 1; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 5; p = 2; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 5; p = 3; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 5; p = 4; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 5; p = 5; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); puts(""); n = 6; p = 0; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 1; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 2; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 3; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 4; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 5; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); n = 6; p = 6; printf("cnp(%d, %d) = %d\n", n, p, cnp_fast(n,p)); } /* -------------------- */ void display_pascal(int n) /* -------------------- */ { } /* ------------------------- */ void display_pascal_fast(int n) /* ------------------------- */ { } /* -------------------------- */ void display_pascal_smart(int n) /* -------------------------- */ { } /* ---------------- */ void test_pascal(void) /* ---------------- */ { int i, n; n=14; puts("=== test_pascal ==="); printf("n=%d\n", n); for(i=1; i<=n; i++) { display_pascal(i); } for(i=1; i<=n; i++) { display_pascal_fast(i); } for(i=1; i<=n; i++) { display_pascal_smart(i); } } /* ================================== */ int main (int argc, const char * argv[]) /* ================================== */ { puts("Hello, World!\n"); test_boucles(); test_prime(); test_factorielle(); test_cnp(); test_pascal(); return 0; }