Problem Description
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
Input
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。每个字符串长度不超过150。
Output
如果一个字符串是回文串,则输出"yes",否则输出"no".
Sample Input
4
level
abcde
noon
haha
Sample Output
yes
no
yes
no
1 #include2 3 #include 4 5 int fun(char a[]) 6 7 { 8 9 int i,k,r=1; 10 11 k=strlen(a)-1; 12 13 for(i=0;i<=k;k--,i++) 14 15 { 16 17 if(a[i]!=a[k]) 18 19 { 20 21 r=0;22 23 break;24 25 }26 27 }28 29 return r;30 31 }32 33 int main()34 35 {36 37 char a[20];38 39 int i,n;40 41 scanf("%d",&n);42 43 for(i=0;i
#include#include int main(){ char str[20]; int n,i,j; scanf("%d",&n); while(n>0) { scanf("%s",str); i=0; j=strlen(str)-1; while(i<=j) { if(str[i]!=str[j]) break; i++; j--; } if(i>j) printf("yes\n"); else printf("no\n"); n--; } return 0;}