题目:
#include <bits/stdc++.h>
using namespace std;
const int maxn=256;
//判断字符串str是否为回文串
bool judge(char str[]){
int len = strlen(str); //字符串长度
for(int i=0;i<len/2;i++){ //枚举字符串的前一半
if(str[i] != str[len-1-i]){ //如果对称位置不同
return false;
}
}
return true; //是“回文串”
}
int main(){
char str[maxn];
while(gets(str)){ //输入字符串
bool flag = judge(str); //判断字符串是否为“回文串”
if(flag==true){ //"回文串"
printf("YES\n");
}else{ //不是回文串
printf("NO\n");
}
}
return 0;
}