#include<stdio.h>
#include<stdlib.h>
#define max 100
typedef struct f{
char data[max];
int front,rear;
}SqQueue;
void Creatqueue(SqQueue* &s)//队的创建
{
s=(SqQueue*)malloc(sizeof(SqQueue));
s->front=s->rear=-1;
}
void pushqueue(SqQueue* &s,char a[])//入队
{
int i=0;
while(a[i]!='\0')
{
s->rear++;
s->data[s->rear]=a[i];
i++;
}
}
void judge(SqQueue* &s)
{
s->front=0;
while(s->data[s->front]==s->data[s->rear])
{
s->front++;
s->rear--;
if(s->front>s->rear)
break;
}
if(s->data[s->front]!=s->data[s->rear])
printf("该字符串不是回文字符串");
else
printf("该字符串是回文字符串");
}
void FreeSqQueue(SqQueue* &s)
{
free(s);
}
int main()
{
SqQueue *L;
char string[max];
printf("----------判断字符串是否为回文字符串------------\n");
printf("请输入所需判断的字符串:\n");
scanf("%s",&string);
Creatqueue(L);
pushqueue(L,string);
judge(L);
FreeSqQueue(L);
return 0;
}