回文序列

A palindrome is a symmetrical string, that is, a string read the same from left to right as from right to left. You are asked to write a program which, given a string, determines whether it is a palindrome or not.

Input
The first line contain a single integer T, indicates the number of test cases.

T lines follow, each line contain a string which you should judge. The length of the string is at most 1000.

Output
Print one line for each string, if it is a palindrome, output “YES”, else “NO”.

Sample Input
2
aba
ab
Sample Output
YES
NO
Hint

#include<stdio.h>
#include<string.h>
int main()
{ int a,i,k,d;
char huahuahua[1000];
scanf("%d",&a);
for(i=1;i<=a;i++)
{ int e=0;
scanf("%s",huahuahua);
d=strlen(huahuahua);
for(k=0;k<d/2;k++)
if(huahuahua[k]!=huahuahua[a-k-1])
{
e=1;
break;//说明不相等
}

	if(e==0)	printf("YES\n");		
	else        printf("NO\n");
}
return 0;

}

回文序列回文序列 火星华晨宇花花花 发布了5 篇原创文章 · 获赞 2 · 访问量 832 私信 关注
上一篇:寒假练习——Palindromes


下一篇:算法竞赛入门经典——数组和字符串