diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-05-06 14:28:59 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-05-06 14:28:59 +0200 |
commit | f0bd9763ea4be22f0f235c0f3aa6628944a56c7e (patch) | |
tree | c12c047b441bdc520740643e549bd90624601fe8 /Semestr 4/sieci/pracownia2/franciszek_malinka/test.c | |
parent | f31c5fa59ee3afafc66bfb53c159eff301b537af (diff) |
Aktualizacja
Diffstat (limited to 'Semestr 4/sieci/pracownia2/franciszek_malinka/test.c')
-rw-r--r-- | Semestr 4/sieci/pracownia2/franciszek_malinka/test.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c new file mode 100644 index 0000000..958ff36 --- /dev/null +++ b/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c @@ -0,0 +1,52 @@ +/* + * Program: router + * Autor: Franciszek Malinka, 316093 + */ + +#include "linked_list.h" +#include <stdlib.h> +#include <stdio.h> + +/* Prints the list of ints to stdio */ +void print_list(list_t list) { + printf("List: "); + reset(&list); + while (list.it != NULL) { + printf("%d, ", *(int *)(list.it->data)); + iterate(&list); + } + printf("\n"); + reset(&list); +} + +int main() { + int n; + scanf("%d", &n); + list_t list = create_list(); + + for (int i = 0; i < n; i++) { + int t; + scanf("%d", &t); + // insert + if (t == 0) { + int val = 0; + scanf("%d", &val); + insert(&list, &val, sizeof(int)); + reset(&list); + } + if (t == 1) { + iterate(&list); + if (list.it != NULL) + printf("it: %d\n", *(int *)list.it->data); + else printf("End of list.\n"); + } + if (t == 2) { + erase_it(&list); + } + if (t == 3) { + print_list(list); + } + } + + free_list(&list); +}
\ No newline at end of file |