判断字符串是否为回文
发布时间
阅读量:
阅读量
题目描述
题目描述
【输入】
输入为一行字符串(字符串中没有空白字符,字符串长度不超过100)。
【输出】
如果字符串是回文,输出yes;否则,输出no。
【输入样例】
abcdedcba
【输出样例】
yes
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
char s[100];
int main()
{
gets(s);
int i=strlen(s)-1;
int j=0;
while((j<i)&&(s[j]==s[i]))
{
i--;
j++;
}
if(j>=i) cout<<"yes"<<endl;
else cout<<"no"<<endl;
return 0;
}
全部评论 (0)
还没有任何评论哟~
