diff options
author | oskar <[email protected]> | 2024-05-11 14:29:07 +0200 |
---|---|---|
committer | oskar <[email protected]> | 2024-05-11 14:29:07 +0200 |
commit | 12e93b4847676ea40ae8a14be639b619449ac52c (patch) | |
tree | 18a4a67400d97c99597e14215d76abcfe14a325f | |
parent | 96651caeeceeefd90a9449aece0e23599370fe9f (diff) |
all linked lists done, i might do some more improvements and code cleanup but the main stuff is done
-rw-r--r-- | cd_linkedlist.c | 27 | ||||
-rw-r--r-- | cs_linkedlist.c | 2 |
2 files changed, 19 insertions, 10 deletions
diff --git a/cd_linkedlist.c b/cd_linkedlist.c index a1226fd..4e0d741 100644 --- a/cd_linkedlist.c +++ b/cd_linkedlist.c @@ -63,17 +63,26 @@ void freellist(struct waster *wr1) { } int main () { - - struct waster *wr1 = llist(20); + + uint64_t passes = 4; + uint64_t passstep = 1; + uint64_t steps = 20; + struct waster *wr1 = llist(steps); struct waster *p; - for (p = wr1 ; p != NULL ; p = p->next) { - void *prev = (void*)p->prev; - void *next = (void*)p->next; - printf("\n------%p----------",(void *)p); - printf("\ndata: %d\nprev: %p\nnext: %p\n", p->gg, prev, next); - printf("-----------------------------\n"); - } + while(passstep < passes+1) { + uint64_t steps_count = 0; + for (p = wr1 ; steps_count < steps ; p = p->next, steps_count++) { + void *prev = (void*)p->prev; + void *next = (void*)p->next; + printf("\n------%p----------",(void *)p); + printf("\ndata: %d\nprev: %p\nnext: %p\n", p->gg, prev, next); + printf("-----------------------------\n"); + } + printf("\npass %lld done\n", passstep); + passstep = passstep+1; + } + printf("\nHEAD: %p\n", (void*)wr1); freellist(wr1); return 0; } diff --git a/cs_linkedlist.c b/cs_linkedlist.c index 1bbbb38..657aeb8 100644 --- a/cs_linkedlist.c +++ b/cs_linkedlist.c @@ -57,7 +57,7 @@ int main () { uint64_t steps = 20; // amount of nodes to create struct waster *wr1 = llist(steps); // Create the nodes - while(passstep != passes) { + while(passstep < passes+1) { uint64_t steps_count = 0; |