2017年省赛前最后一水---A题

来源:互联网 发布:阿里云服务器如何重启 编辑:程序博客网 时间:2024/05/22 01:43

问题 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****************************************************************/
0 0
原创粉丝点击