X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_9%2Fexo2%2Fexo2.c;fp=TP_9%2Fexo2%2Fexo2.c;h=15172cee30296de07f8e18242bd7c0bfd30c20f4;hb=f8051b356ef079c703c1dc0369a135b5032f4027;hp=0000000000000000000000000000000000000000;hpb=0c2d94f5a32e95d2117d9204dbdd79d878c23b69;p=TD_C.git diff --git a/TP_9/exo2/exo2.c b/TP_9/exo2/exo2.c new file mode 100644 index 0000000..15172ce --- /dev/null +++ b/TP_9/exo2/exo2.c @@ -0,0 +1,26 @@ +#include + +#include "clist.h" + +int main() { + 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)); + list_clear(head); + + return 0; +}