TP11 exo2: Finish the asked features implementation
[TD_C.git] / TP_11 / exo2 / exo2.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <stdbool.h>
4
5 #include "ui.h"
6
7 int main() {
8 link_t* head = NULL;
9 unsigned counter = 0;
10 int value = 0;
11 int promptrtVal = 0;
12 int* array = NULL;
13
14 while (true) {
15 promptrtVal = promptValue("Saisir une valeur:", &value);
16 if (promptrtVal != 0)
17 break;
18 head = list_append(head, value);
19 counter++;
20 }
21 printf("Liste:\n");
22 displayList(head);
23 array = malloc(counter*sizeof(int));
24 array[0] = list_get(head, 0);
25 for (unsigned i = 1; i < counter; i++) {
26 array[i] = array[i-1] + list_get(head, i);
27 }
28 printf("Tableau des sommes:\n");
29 displayArray(array, counter);
30 list_clear(head);
31 free(array);
32
33 return 0;
34 }