SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. void push_queue(struct Node* tail, int val){
  4.    
  5.     if(tail==head){
  6.         struct Node* cur = (struct Node*)malloc(sizeof(struct Node));
  7.         cur->val=val;
  8.         cur->next =NULL;
  9.         tail=cur;
  10.         head->next = tail;
  11.     }
  12.     if(tail==NULL){
  13.         head->val = tail->val = val;
  14.         head->next = tail->next = NULL;
  15.     }
  16.     struct Node* cur = (struct Node*)malloc(sizeof(struct Node));
  17.     cur->next = NULL;
  18.     cur->val = val;
  19.     tail->next=cur;
  20.     tail = cur;
  21. }
  22.  
  23. struct Node* pop_queue(struct Node* head, int val){
  24.     Node* cur = head;
  25.     if(head==NULL){
  26.         cout << "queue is empty" << endl;
  27.         return 0;
  28.     }
  29.     head=head->next;
  30.     return cur;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top