#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define MAX 100
typedef char ElemType;
//定义栈结构体
struct stack
{
    ElemType elem[MAX];
    int top;//顶部下标
};
//初始化栈
void initStack(struct stack *s)
{
    s=(struct stack *)malloc(sizeof(struct stack));
    s->top=-1;
}
//入栈
void inStack(struct stack *s,ElemType data)
{
    //判断栈是否满
    if(s->top==MAX-1)
    {
        printf("栈满!");
    }
    else{
        s->top++;
        s->elem[s->top]=data;

    }
}
void outStack(struct stack *s,ElemType x)
{
    //判断栈是否为空
    if(s->top==-1)
    {
        printf("栈空");
    }
    else{
        x=s->elem[s->top];
        s->top--;
    }
}
//队列结构体
struct Queue{
    ElemType elem[MAX];
    int rear;//尾部下标
    int front;//头部下标
};
//初始化队列
void initQueue(struct Queue *q)
{
    q=(struct Queue *)malloc(sizeof(struct Queue));
    q->front=q->rear=0;
}
//进队
void inQueue(struct Queue *q,ElemType data)
{
    //先判断队列是否满
    if(q->rear==MAX-1)
    {
        printf("栈已满!");
    }
    else
    {
        q->rear++;
        q->elem[q->rear]=data;


    }
}
//出队
void outQueue(struct Queue *q,ElemType y)
{
    //先判断队列是否为空
    if(q->front==q->rear)
    {
        printf("对空");
    }
    else
    {
        q->front++;
        y=q->elem[q->front];


    }
}
//判断是否为回文数
int judge(struct stack *s,struct Queue *q)
{
    int count=0;
    int i;
    int flag=1;
    char ch;
    char ch1;
    char ch2;
    while(ch=getchar()!='@')
    {
        inStack(s,ch);
        inQueue(q,ch);
        count++;
    }
    if(count%2!=0 && s->elem[(count+1)/2]=='&')
    {
        while(i<count)
        {
            outStack(s,ch1);//出栈
            outQueue(q,ch2);//出队
            i++;
            if(ch1==ch2)
            {
               flag=1;

               continue;
            }
            else
            {

                flag=0;
                break;
            }
        }
    }
    else{

        flag=0;
    }
    return flag;
}
int main()
{

    struct stack *s;
    initStack(s);
    struct Queue *q;
    initQueue(q);
    int t=judge(s,q);
    if(t==1)
    {
        printf("是回文数!");
    }
    else{
        printf("不是回文数!");
    }
    return 0;
}