Advertisement
KiK0S

Untitled

Mar 8th, 2021
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <stddef.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. struct ListItem
  7. {
  8.     struct ListItem *prev, *next;
  9.     uint64_t value;
  10. };
  11.  
  12. struct List
  13. {
  14.     struct ListItem *first, *last;
  15. };
  16.  
  17. struct ListItem *to_front(struct List *lst, uint64_t value, size_t maxsize) ;
  18. int main(int argc, char **argv) {
  19.     struct List lst;
  20.     lst.first = NULL;
  21.     lst.last = NULL;
  22.     to_front(&lst, 4, 10);
  23.     to_front(&lst, 3, 10);
  24.     to_front(&lst, 2, 10);
  25.     to_front(&lst, 1, 10);
  26.     to_front(&lst, 5, 3);
  27.     struct ListItem *current = lst.first;
  28.     while (current) {
  29.         printf("%ld\n", current->value);
  30.         current = current->next;
  31.     }
  32.     printf("\n");
  33.     current = lst.last;
  34.     while (current) {
  35.         printf("%ld\n", current->value);
  36.         current = current->prev;
  37.     }
  38.     return 0;
  39.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement