Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void push_queue(struct Node* tail, int val){
- if(tail==head){
- struct Node* cur = (struct Node*)malloc(sizeof(struct Node));
- cur->val=val;
- cur->next =NULL;
- tail=cur;
- head->next = tail;
- }
- if(tail==NULL){
- head->val = tail->val = val;
- head->next = tail->next = NULL;
- }
- struct Node* cur = (struct Node*)malloc(sizeof(struct Node));
- cur->next = NULL;
- cur->val = val;
- tail->next=cur;
- tail = cur;
- }
- struct Node* pop_queue(struct Node* head, int val){
- Node* cur = head;
- if(head==NULL){
- cout << "queue is empty" << endl;
- return 0;
- }
- head=head->next;
- return cur;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement