Description
输入一个字符串,输出该字符串是否回文。回文是指顺读和倒读都一样的字符串。
输入格式
输入为一行字符串(字符串中没有空白字符,字符串长度不超过 100100)。
输出格式
如果字符串是回文,输出
"yes"
;否则,输出"no"
。输出时每行末尾的多余空格,不影响答案正确性
样例输入
abcdedcba
样例输出
yes
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
char s[105];
int main()
{
int len;
int i;
while (~scanf("%s", s)){
len = strlen(s);
for (i = 0; i <= len/2; i++)
if (s[i] != s[len-1-i]){
printf("no\n");
break;
}
if (i == len/2+1)
printf("yes\n");
}
return 0;
}