第1个回答 2021-11-04
#include<iostream>
#include<string.h>
using namespace std;
int main(){
char str[200];
int n;
int flag=0;//标记变量初值为0
cin>>str;
n=strlen(str);//调用库函数获取字符串长度
for(int i=0;i<n;i++){
if(str[i]!=str[n-i-1]){//前后对应位置字符不同
cout<<"不是回文字符串"<<endl;
flag=1;//标记一下
break;//提前结束
}
}
if(flag==0){//未被标记,是回文字符串
cout<<"是回文字符串"<<endl;
}
return 0;
}本回答被提问者采纳