Hangzhou Electric Oj brush title (2029)

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 
haha

Sample 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;
}

 

Published 55 original articles · won praise 0 · Views 1010

Guess you like

Origin blog.csdn.net/ZhangShaoYan111/article/details/104155438