Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stddef.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- struct ListItem
- {
- struct ListItem *prev, *next;
- uint64_t value;
- };
- struct List
- {
- struct ListItem *first, *last;
- };
- struct ListItem *to_front(struct List *lst, uint64_t value, size_t maxsize) ;
- int main(int argc, char **argv) {
- struct List lst;
- lst.first = NULL;
- lst.last = NULL;
- to_front(&lst, 4, 10);
- to_front(&lst, 3, 10);
- to_front(&lst, 2, 10);
- to_front(&lst, 1, 10);
- to_front(&lst, 5, 3);
- struct ListItem *current = lst.first;
- while (current) {
- printf("%ld\n", current->value);
- current = current->next;
- }
- printf("\n");
- current = lst.last;
- while (current) {
- printf("%ld\n", current->value);
- current = current->prev;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement