#include<stdio.h>
typedef struct
{
char str1[200];
int size;
}stack;
typedef struct
{
char str2[200];
int front;
int rear;
}queue;
void initstack(stack& L)
{
L.size = 0;
}
void initqueue(queue& K)
{
K.front = K.rear = 0;
}
bool enqueue(queue& K, char c)
{
if (K.rear == 201)
return false;
K.str2[K.rear]=c;
K.rear++;
return true;
}
bool pushstack(stack& L, char d)
{
if (L.size == 201)
return false;
L.str1[L.size] = d;
L.size++;
return true;
}
bool popstack(stack& L, char& a)
{
if (L.size == 0)
return false;
a = L.str1[L.size - 1];
L.size--;
return true;
}
bool outqueue(queue& K, char& b)
{
if (K.front == K.rear)
return false;
b = K.str2[K.front];
K.front++;
return true;
}
int main()
{
char a, b;
queue K;
stack L;
initqueue(K);
initstack(L); //要记得初始化!!!
char v;
int cnt = 0; //用来控制出队出栈
while ((v = getchar()) != '#')
{
cnt++;
enqueue(K, v);
pushstack(L, v);
}
int flag = 1;
while (cnt--)
{
popstack(L, a);
outqueue(K, b);
if (a != b)
{
flag = 0;
break;
}
}
if (flag)printf("是回文数列");
else printf("不是回文数列");
return 0;
}