CodeForces - 691B s-palindrome (字符串,模拟)

Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.

English alphabet

You are given a string s. Check if the string is "s-palindrome".

Input

The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.

Output

Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.

Example
Input
oXoxoXo
Output
TAK
Input
bod
Output
TAK
Input
ER
Output
NIE


题意:判断一个字符串是否是对称的,是的话输出TAK,否则输出NIE。

首先要找出对称的字母,注意m、n两个字母不对称!

还要注意,b和d对称,p和q对称!

另外注意字符串对称的写法!

代码如下:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char *s="AHIMOoTUVvWwXxY";
    char a[1010];
    bool flag=true;
    scanf("%s",a);
    for(int i=0;i<=strlen(a)/2;i++)
    {
        if(a[i]!=a[strlen(a)-i-1])
        {
            if((a[i]=='b'&&a[strlen(a)-i-1]=='d')||(a[i]=='d'&&a[strlen(a)-i-1]=='b'));
            else if((a[i]=='p'&&a[strlen(a)-i-1]=='q')||(a[i]=='q'&&a[strlen(a)-i-1]=='p'));
            else flag=false;
        }
       if((a[i]=='b'&&a[strlen(a)-i-1]=='d')||(a[i]=='d'&&a[strlen(a)-i-1]=='b'));
            else if((a[i]=='p'&&a[strlen(a)-i-1]=='q')||(a[i]=='q'&&a[strlen(a)-i-1]=='p'));//这样写是为了能判断到中间的字母是否对称,但是没有中间字母的时候会错开
        else if(strchr(s,a[i])==NULL)
        {
            flag=false;
        }
    }
    if(flag==true)
    {
        printf("TAK\n");
    }
    else
    {
        printf("NIE\n");
    }
}


转载于:https://www.cnblogs.com/lbq-home/p/9784622.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值