Sei sulla pagina 1di 1

#include "pch.

h"
#include <iostream>
using namespace std;
class Node
{
public:
int data;
Node *next; Node *prev;
Node(int val)
{
data = val;
next = NULL;
prev = NULL;
}
};

class QueueList
{
public:
Node *head, *tail;
QueueList()
{
head = tail = NULL;
}
void Enque(int val)
{
Node *temp;
temp = new Node[val];
if (head == NULL)
{
head = tail = temp;
}
else
{
tail->next = temp; temp->prev = tail;
tail = temp;
}
}
int Deque()
{
int i; Node *ptr = head;
i = head->data;
head = head->next;
head->prev = NULL;
ptr->next = NULL;
delete ptr;
return i;
}
};

Potrebbero piacerti anche