【NEEPU OJ】1013--Palindrome

描述

Give the definition of a new word:
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.
We want you to write a program that can check whether a given input is palindrome or not. The input will only contain English alphabets and digits. Remember, in this task, uppercase and lowercase letter count as same.

输入

Input starts with an integer T (≤ 1000), denoting the number of test cases. Each test case will have one line containing the text to test. You can assume that each input text will be less than 100 characters in length.

输出

For each test case, print either “Yes” (without quotes) or “No” (without quotes). If the input text is palindrome then print “Yes”, otherwise print “No”

输入样例 1

3
abababa
ababab
1EYE1

输出样例 1

Yes
No
Yes

来源

NEEPU_ACM_2017_训练赛(2)


代码
#include <cstdio>
#include <cstring>
using namespace std;

void judge(char a[]){
    int i = 0, j = strlen(a) - 1;
    for(int k = 0; k <= j; k++){
        if(a[k] >= 65 && a[k] <= 90) a[k] += 32;
    }
    while(i < j){
        if(a[i] != a[j]) break;
        i++;
        j--;
    }
    if(i >= j) printf("Yes\n");
    else printf("No\n");
}

int main(){
    int n;
    char a[101];
    scanf("%d", &n);
    while(n--){
        scanf("%s", a);
        judge(a);
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值