X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_13%2Fexo1%2Fsrc%2Fmain.c;h=2c81a631b28d3abb19c28c4eb6bf4d0ce3e0bd7f;hb=889d586254feccc26f294af86ce7e698ea006dfb;hp=ea4abc39e67b739c04fcba45a5f142a0f2a31491;hpb=cfdd46d2e85b05f77a03ae31f721e2fd4030996f;p=TD_C.git diff --git a/TP_13/exo1/src/main.c b/TP_13/exo1/src/main.c index ea4abc3..2c81a63 100644 --- a/TP_13/exo1/src/main.c +++ b/TP_13/exo1/src/main.c @@ -8,16 +8,44 @@ int main() { int* tab = NULL; unsigned tab_size = 0; + int errno = 0; + int choice = 0; + printf("=== Saisie initiale ===\n\n"); tab = prompt_array(tab, &tab_size); - printf("%d\n", tab_size); - - display_array(tab, tab_size); - - sort_tab(tab, tab_size, ascending_and_odd); - - display_array(tab, tab_size); + do { + display_choice_menu(); + errno = prompt_value("Choix?", &choice); + handle_prompt_error(errno); + if (1 > choice || 7 < choice) { + printf("\nFaire un choix compris entre 1 et 7\n"); + continue; + } + switch (choice) { + case 1: + tab = do_concat(tab, &tab_size); + break; + case 2: + do_sort(tab, tab_size); + break; + case 3: + display_array(tab, tab_size); + break; + case 4: + do_count(tab, tab_size); + break; + case 5: + printf("\nLe nombre d'entiers pairs dans le tableau est %d\n", count_tab_criteria(tab, tab_size, is_even)); + break; + case 6: + printf("\nLe nombre d'entiers impairs dans le tableau est %d\n", count_tab_criteria(tab, tab_size, is_odd)); + break; + default: + /* do nothing, unused code path */ + break; + } + } while (choice != 7); free_tab(tab); exit(EXIT_SUCCESS);