TP11 exo2: Finish the asked features implementation
[TD_C.git] / TP_11 / exo2 / exo2.c
CommitLineData
fabfe86c 1#include <stdlib.h>
a5a96953 2#include <stdio.h>
fabfe86c 3#include <stdbool.h>
a5a96953 4
a5a96953
JB
5#include "ui.h"
6
7int main() {
a5a96953 8 link_t* head = NULL;
fabfe86c
JB
9 unsigned counter = 0;
10 int value = 0;
11 int promptrtVal = 0;
12 int* array = NULL;
a5a96953 13
fabfe86c
JB
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");
a5a96953 22 displayList(head);
fabfe86c
JB
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);
a5a96953 30 list_clear(head);
fabfe86c 31 free(array);
a5a96953
JB
32
33 return 0;
34}