#include<iostream>
using namespace std;
struct Node
{
int data;
Node* next;
};
Node* front = NULL;
Node* rear = NULL;
void Enqueue(int x)
{
Node* temp = new Node;
temp->data = x;
temp->next = NULL;
if(front == NULL && rear == NULL)
{
front = rear = temp;
return;
}
rear->next = temp;
rear = temp;
}
void Dequeue()
{
Node* temp = front;
if(front == NULL) return;
if(front == rear)
front = rear = NULL;
else
front = front->next;
delete temp;
}
bool IsEmpty()
{
return front == NULL ? true : false;
}
int Front()
{
return front->data;
}
void Print()
{
Node* temp = front;
printf("queue:\n");
while(temp->next != NULL)
{
printf("%d ",temp->data);
temp = temp->next;
}
printf("\n");
}
int main()
{
Enqueue(4);
printf("The front of queue is %d\n",Front());
Print();
Enqueue(2);
printf("The front of queue is %d\n",Front());
Print();
Enqueue(11);
printf("The front of queue is %d\n",Front());
Print();
Enqueue(61);
printf("The front of queue is %d\n",Front());
Print();
Dequeue();
printf("The front of queue is %d\n",Front());
Print();
return 0;
}