Advertisement
dusanrs

lista

Apr 28th, 2022
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #ifndef LIST_H_INCLUDED
  2. #define LIST_H_INCLUDED
  3.  
  4. // kruzna lista sa granicnikom
  5.  
  6. typedef struct node {
  7.     int data;
  8.     struct node *next;
  9. } node;
  10. /*
  11. void init(node **l);
  12.  
  13. void addBegin(node *l, int s);
  14.  
  15. void addEnd(node **l, int s);
  16.  
  17.  
  18. void init(node **l){
  19.   *l = (node*) malloc(sizeof(node));
  20.   (*l)->next = *l;
  21. };
  22. */
  23.  
  24. void addBegin(node *l, int s){
  25.    node *temp = (node*) malloc(sizeof(node));
  26.    temp->data = s;
  27.    temp->next = l->next;
  28.    l->next = temp;
  29. };
  30.  
  31. void addEnd(node **l, int s){
  32.    node *temp = (node*) malloc(sizeof(node));
  33.    // dodajemo podatak u granicnik
  34.    (*l)->data = s;
  35.    temp->next = (*l)->next;
  36.    (*l)->next = temp;
  37.    *l = temp;
  38. };
  39.  
  40.  
  41. #endif
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement