code4sk/c/sourcecode/朱森森带领的奇妙冒险/字符串1/判断回文.cpp
2023-10-18 16:17:32 +08:00

38 lines
648 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//判断回文
//输入一个以回车符为结束标志的字符串少于80个字符判断该字符串是否为回文。
//回文就是字符串中心对称如“abcba”、“abccba”是回文“abcdba”不是回文。
//输入格式:
//输入一个以回车符为结束标志的字符串少于80个字符
//输出格式:
//为回文输出yes; 非回文输出no注意输出的结果后面有回车符
//输入样例:
//abccba
//输出样例:
//yes
#include<stdio.h>
#include<string.h>
int main()
{
int n,i;
char line[80];
gets(line);
n=strlen(line);
for(i=0;i<n/2;i++)
{
if(line[i]!=line[n-1-i])
break;
}
if(i>=n/2)
printf("yes\n");
else
printf("no\n");
return 0;
}