X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_9%2Fexo2%2Fexo2.c;h=810bd9eea64545915da2dfa27ec3ff4f52384c3c;hb=4a758ce5f71ecc19fb6457595fb04c18b6918b9f;hp=3b62ea4620b90f7ffa7dffa6307d15163391a350;hpb=3de00528618f48f669d1b2ff673fd1370cdf5323;p=TD_C.git diff --git a/TP_9/exo2/exo2.c b/TP_9/exo2/exo2.c index 3b62ea4..810bd9e 100644 --- a/TP_9/exo2/exo2.c +++ b/TP_9/exo2/exo2.c @@ -3,35 +3,43 @@ #include "clist.h" int main() { + link_t* head1 = NULL; + link_t* head2 = NULL; link_t* head = NULL; - printf("Longueur de la liste: %d\n", list_count(head)); - head = list_append(head, 1); - head = list_append(head, 2); - head = list_append(head, 3); - head = list_append(head, 4); - printf("Longueur de la liste: %d\n", list_count(head)); - printf("Valeur a index %d: %d\n", 0, list_get(head, 0)); - printf("Valeur a index %d: %d\n", 1, list_get(head, 1)); - printf("Valeur a index %d: %d\n", 2, list_get(head, 2)); - printf("Valeur a index %d: %d\n", 3, list_get(head, 3)); - head = list_prepend(head, 5); - printf("Longueur de la liste: %d\n", list_count(head)); - printf("Valeur a index %d: %d\n", 0, list_get(head, 0)); - printf("Valeur a index %d: %d\n", 4, list_get(head, 4)); - list_set(head, 0, 78); - printf("Valeur a index %d: %d\n", 0, list_get(head, 0)); - printf("Valeur a index %d: %d\n", 1, list_get(head, 1)); - printf("Valeur a index %d: %d\n", 2, list_get(head, 2)); - head = list_insert(head, 2, 7); - printf("Valeur a index %d: %d\n", 1, list_get(head, 1)); - printf("Valeur a index %d: %d\n", 2, list_get(head, 2)); - printf("Valeur a index %d: %d\n", 3, list_get(head, 3)); - head = list_delete(head, 3); - printf("Valeur a index %d: %d\n", 0, list_get(head, 0)); - printf("Valeur a index %d: %d\n", 1, list_get(head, 1)); - printf("Valeur a index %d: %d\n", 2, list_get(head, 2)); - printf("Valeur a index %d: %d\n", 3, list_get(head, 3)); - printf("Valeur a index %d: %d\n", 4, list_get(head, 4)); + + 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)); + list_display_values(head1); + head1 = list_prepend(head1, 5); + printf("Longueur de la liste: %d\n", list_count(head1)); + list_display_values(head1); + list_set(head1, 0, 78); + list_display_values(head1); + head1 = list_insert(head1, 2, 7); + list_display_values(head1); + head1 = list_delete(head1, 3); + list_display_values(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); + list_display_values(head1); + head2 = list_insert(head2, 0, 8); + head2 = list_append(head2, 6); + head2 = list_prepend(head2, 5); + list_display_values(head2); + head = list_concat(head1, head2); + list_display_values(head); + head = list_merge_sort(head); + //head = list_sort(head); + list_display_values(head); + //list_clear(head1); + //list_clear(head2); list_clear(head); return 0;