diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-04-19 08:41:26 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-04-19 08:41:26 +0200 |
commit | 1078d2387db43d0c7e982d1ba3340dc67fe0fed9 (patch) | |
tree | ebb144225320e2559b29cc49efb6b5eea03183c5 /Semestr 4/sieci/pracownia2/router/test.c | |
parent | 4167f191cec04314082896ca4618663e97b4f4f1 (diff) |
Router update
Diffstat (limited to 'Semestr 4/sieci/pracownia2/router/test.c')
-rw-r--r-- | Semestr 4/sieci/pracownia2/router/test.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Semestr 4/sieci/pracownia2/router/test.c b/Semestr 4/sieci/pracownia2/router/test.c new file mode 100644 index 0000000..ebc6df1 --- /dev/null +++ b/Semestr 4/sieci/pracownia2/router/test.c @@ -0,0 +1,40 @@ +#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)); + } + if (t == 1) { + erase(&list); + } + if (t == 2) { + print_list(list); + } + } + + free_list(&list); +}
\ No newline at end of file |