#include <iostream>
#include <stdio.h>
#define MaxSize 5
typedef int ElemType;
typedef struct {
ElemType data[MaxSize];
int top;
}SqStack;
void InitStack(SqStack &S)
{
S.top=-1;
}
bool StackEmpty(SqStack S)
{
if(S.top==-1)
{
return true;
}
return false;
}
bool Push(SqStack &S,ElemType m)
{
if(S.top==MaxSize-1)
{
return false;
}
S.data[++S.top]=m;
return true;
}
bool GetTop(SqStack S,ElemType &m) {
if(StackEmpty(S))
{
return false;
}
m=S.data[S.top];
return true;
}
bool Pop(SqStack &S,ElemType &m)
{
if(StackEmpty(S))
{
return false;
}
m=S.data[S.top--];
return true;
}
typedef struct {
ElemType data[MaxSize];//只能存储MaxSize-1个元素
int front,rear;
}SqQueue;
void InitSqQuence(SqQueue &Q)
{
Q.rear=Q.front=0;
}
bool IsEmpty(SqQueue Q)
{
if(Q.rear==Q.front)
{
return true;
}
return false;
}
bool EnQueue(SqQueue &Q,ElemType e)
{
if((Q.rear+1)%MaxSize==Q.front)
{
return false;
}
Q.data[Q.rear]=e;
Q.rear=(Q.rear+1)%MaxSize;
return true;
}
bool DeQueue(SqQueue &Q,ElemType &e)
{
if(Q.rear==Q.front)
{
return false;
}
e=Q.data[Q.front];
Q.front=(Q.front+1)%MaxSize;
return true;
}
int main() {
SqStack S;
bool flag;
ElemType m,p;
InitStack(S);
for (int i = 0; i < 3; ++i) {
scanf("%d",&p);
Push(S,p);
}
for (int i = 0; i < 3; ++i) {
Pop(S,m);
printf("%2d",m);
}
printf("\n");
SqQueue Q;
InitSqQuence(Q);
for (int i = 0; i < 5; ++i) {
scanf("%d",&p);
flag=EnQueue(Q,p);
if(false==flag)
{
printf("false\n");
}
}
for (int i = 0; i < 5; ++i) {
flag=DeQueue(Q,m);
if(flag== false)
{
break;
}
printf("%2d",m);
}
printf("\n");
return 0;
}