Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- struct Node
- {
- int body;
- Node* next;
- Node* previous;
- Node()
- {
- body = 0;
- next = NULL;
- }
- };
- class Queue
- {
- Node* head;
- Node* tail;
- public:
- Queue()
- {
- this->head = NULL;
- this->tail = NULL;
- }
- Queue(const Queue& obj)
- {
- this->head = obj.head;
- this->tail = obj.tail;
- }
- void push( int element)
- {
- Node* link = new Node;
- link->body = element;
- if (head->next != NULL)
- {
- this->head = link;
- this->tail = link;
- }
- else
- {
- link->body = element;
- tail->next = link;
- link->previous = tail;
- tail = tail->next;
- }
- }
- int pop()
- {
- Node* link = tail;
- int el = link->body;
- tail = tail->previous;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement