+#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
-#include "clist.h"
#include "ui.h"
int main() {
- link_t* head1 = NULL;
- link_t* head2 = NULL;
link_t* head = NULL;
+ unsigned counter = 0;
+ int value = 0;
+ int promptrtVal = 0;
+ int* array = NULL;
- printf("Longueur de la liste: %d\n", list_count(head1));
- head1 = list_append(head1, 1);
- head1 = list_append(head1, 2);
- head1 = list_append(head1, 3);
- head1 = list_append(head1, 4);
- printf("Longueur de la liste: %d\n", list_count(head1));
- displayList(head1);
- head1 = list_prepend(head1, 5);
- printf("Longueur de la liste: %d\n", list_count(head1));
- displayList(head1);
- list_set(head1, 0, 78);
- displayList(head1);
- head1 = list_insert(head1, 2, 7);
- displayList(head1);
- head1 = list_delete(head1, 3);
- displayList(head1);
- head1 = list_append(head1, 5);
- head1 = list_append(head1, 12);
- head1 = list_append(head1, 65);
- head1 = list_append(head1, 21);
- head1 = list_sort(head1);
- displayList(head1);
- head2 = list_insert(head2, 0, 8);
- head2 = list_append(head2, 6);
- head2 = list_prepend(head2, 5);
- displayList(head2);
- head = list_concat(head1, head2);
+ while (true) {
+ promptrtVal = promptValue("Saisir une valeur:", &value);
+ if (promptrtVal != 0)
+ break;
+ head = list_append(head, value);
+ counter++;
+ }
+ printf("Liste:\n");
displayList(head);
- head = list_merge_sort(head);
- //head = list_sort(head);
- displayList(head);
- //list_clear(head1);
- //list_clear(head2);
+ array = malloc(counter*sizeof(int));
+ array[0] = list_get(head, 0);
+ for (unsigned i = 1; i < counter; i++) {
+ array[i] = array[i-1] + list_get(head, i);
+ }
+ printf("Tableau des sommes:\n");
+ displayArray(array, counter);
list_clear(head);
+ free(array);
return 0;
}