问题 A: String
时间限制: 1 Sec 内存限制: 128 MB
提交: 118 解决: 78
[提交][状态][讨论版]
题目描述
Lucy give you a string s(s1s2s3…sn) .
If(s1s2s3…sn)=(snsn-1sn-2…s1) ,you tell Lucy YES,otherwise ,you tell Lucy NO.
For example.
Lucy give you “abba”,you should tell her “YES”
Lucy give you “abbc”,you should tell her “NO”
Lucy give you “abxba”,you should tell her “YES”
输入
The first line of the input gives the number of test cases T(1
#include <stdio.h>
#include <string.h>
int main()
{
char str[1005];
int n;
while(~scanf("%d",&n))
{
for(int k = 1;k<=n;k++)
{
int flag =1;
scanf("%s",str);
int length = strlen(str);
for(int i = 0;i< length/2+1;i++)
{
if(str[i] != str[length-i-1])
{
flag = 0;
break;
}
}
if(flag)
printf("Case #%d: YES\n",k);
else
printf("Case #%d: NO\n",k);
}
}
return 0;
}
/**************************************************************
Problem: 1011
User: T032
Language: C++
Result: 正确
Time:36 ms
Memory:956 kb
****************************************************************/