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

问题 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
****************************************************************/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值