Palindrome string
Subject description:
"Palindrome string" is a positive reading and verlan same string, such as "level" or "noon" and so is a palindrome string. Please write a program to determine whether the read string is "palindrome."
Input
Comprising a plurality of test input example, the first line of input data is a positive integer n, the number of test examples, is immediately followed by a string of n.
Output
If a string is a palindrome string, the output is "yes", otherwise output "no".
Sample Input
4 level abcde noon hahaSample Output
yes no yes no
By the answer:
#include <stdio.h>
#include<string.h>
int main() {
int n, i,len,flag;
char str[100];
while (scanf("%d", &n)!=EOF) {
getchar();
while(n--){
gets(str);
len=strlen(str);
flag=0;
for(i=0;i<len;i++){
if(str[i]!=str[len-i-1]){ //回文串判断
flag++;
break;
}
}
if(flag==0)
printf("yes\n");
else
printf("no\n");
}
}
return 0;
}