#include<stdio.h>
#include<string.h>
#include<queue>
#include<iostream>
using namespace std;
int main()
{
int T;
while(scanf("%d",&T)!=EOF)
{
getchar();
queue<int>q;
while(T--)
{
char s[20];
scanf("%s",s);
if(strcmp(s,"enqueue")==0)
{
int n;
scanf("%d",&n);
q.push(n);
}
if(strcmp(s,"dequeue")==0)
{
if(q.empty())
printf("this is empty!\n");
else
{
cout << q.front() << endl;
q.pop();
}
}
if(strcmp(s,"query")==0)
{
if(q.empty())
printf("this is empty!\n");
else
{
while(!q.empty())
{
cout << q.front() << endl;
q.pop();
}
}
}
}
printf("\n");
}
}
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#define maxsize 100
typedef struct que
{
int a[maxsize];
int front;
int rear;
} queue;
void Initqueue(queue *q)
{
q->front=q->rear=0;
}
void Insertqueue(queue *q,int e)
{
q->a[q->rear]=e;
q->rear++;
}
void Deletequeue(queue *q)
{
if(q->front==q->rear)
{
printf("this is empty!\n");
}
// e=q->a[q->front];
else
{
int e=q->a[q->front];
printf("%d\n",e);
q->front++;
}
}
void query(queue *q)
{
while(q->front!=q->rear)
{
int e=q->a[q->front];
printf("%d\n",e);
q->front++;
}
}
int main()
{
int T;
queue *q=(queue *)malloc(sizeof(queue));
while(scanf("%d",&T)!=EOF)
{
Initqueue(q);
while(T--)
{
char b[200];
int e;
getchar();
scanf("%s",b);
if(strcmp(b,"enqueue")==0)
{
scanf("%d",&e);
Insertqueue(q,e);
}
if(strcmp(b, "dequeue")==0)
{
Deletequeue(q);
}
if(strcmp(b,"query")==0)
{
if(q->front==q->rear)
printf("this is empty!\n");
else
query(q);
}
}
printf("\n");
}
}