/*Palindromes _easy version Problem Description “回文串”它是一个正读和反读同一字符串。例“level”要么“noon”等是回文序列。请编写一个程序,读取推断字符串是否“回文”。
Input 输入包括多个測试实例,输入数据的第一行是一个正整数n,表示測试实例的个数。后面紧跟着是n个字符串。
Output 假设一个字符串是回文串。则输出"yes",否则输出"no".
Sample Input 4 level abcde noon haha
Sample Output yes no yes no
*/
#include<stdio.h> #include<string.h> int main() { char str[100010]; int test,len,i,j; while(~scanf("%d",&test)) { getchar();//注意getchar();的位置。
while(test--) { gets(str); len=strlen(str); for(i=0,j=len-1;i<j;i++,j--)//字符串中第一个字符与最好一个字符作比較 if(str[i]!=str[j]) { printf("no\n"); break; } if(i>=j) printf("yes\n"); } } return 0; }
版权声明:本文博客原创文章,博客,未经同意,不得转载。
转载于:https://www.cnblogs.com/gcczhongduan/p/4666790.html
相关资源:垃圾分类数据集及代码