数据结构
队列实现回文字符串判断
#include<stdio.h>
#include<queue>
#include<cstring>
using namespace std;
int main(){
queue <char>q;
char a[100];
scanf("%s",&a);
int len=strlen(a);
for(int i=0;i<len;i++)
q.push(a[i]);
int flag=0;
for(int i=len-1;i>=0;i--)
{
char temp=q.front();
if(a[i]!=temp)
{
flag=1;
break;
}
q.pop();
}
if(flag==0)
printf("该字符串是回文字符串");
else
printf("该字符串不是回文字符串");
}

浙公网安备 33010602011771号