题目描述:
输入一个字符串,输出该字符串是否回文。回文是指顺读和倒读都一样的字符串。
输入格式:
输入为一行字符串(字符串中没有空白字符,字符串长度不超过100)。
输出格式:
如果字符串是回文,输出yes;否则,输出no。
输入样例:
abcdedcba
输出样例:
yes
AC代码:
#include <iostream>
#include <cstring>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main(){
char ch[50];
int i,len;
scanf("%s",ch);
len=strlen(ch);
for(i=0;i<=len/2;)
{
if(ch[i]!=ch[len-i-1])
{
printf("no");
exit(0);
}
i++;
}
printf("yes");
return 0;
}