TP 9 exo2: Implement a merge sort function for the linked list.
[TD_C.git] / TP_9 / exo2 / exo2.c
CommitLineData
f8051b35
JB
1#include <stdio.h>
2
3#include "clist.h"
4
5int main() {
970a0122
JB
6 link_t* head1 = NULL;
7 link_t* head2 = NULL;
f8051b35 8 link_t* head = NULL;
970a0122
JB
9
10 printf("Longueur de la liste: %d\n", list_count(head1));
11 head1 = list_append(head1, 1);
12 head1 = list_append(head1, 2);
13 head1 = list_append(head1, 3);
14 head1 = list_append(head1, 4);
15 printf("Longueur de la liste: %d\n", list_count(head1));
16 list_display_values(head1);
17 head1 = list_prepend(head1, 5);
18 printf("Longueur de la liste: %d\n", list_count(head1));
19 list_display_values(head1);
20 list_set(head1, 0, 78);
21 list_display_values(head1);
22 head1 = list_insert(head1, 2, 7);
23 list_display_values(head1);
24 head1 = list_delete(head1, 3);
25 list_display_values(head1);
26 head1 = list_append(head1, 5);
27 head1 = list_append(head1, 12);
28 head1 = list_append(head1, 65);
29 head1 = list_append(head1, 21);
30 head1 = list_sort(head1);
31 list_display_values(head1);
32 head2 = list_insert(head2, 0, 8);
33 head2 = list_append(head2, 6);
34 head2 = list_prepend(head2, 5);
35 list_display_values(head2);
36 head = list_concat(head1, head2);
83ec54cd 37 list_display_values(head);
4a758ce5
JB
38 head = list_merge_sort(head);
39 //head = list_sort(head);
65544a82 40 list_display_values(head);
970a0122
JB
41 //list_clear(head1);
42 //list_clear(head2);
f8051b35
JB
43 list_clear(head);
44
45 return 0;
46}