CodeForces
来源:互联网 发布:MT7623GA芯片数据 编辑:程序博客网 时间:2024/06/06 01:21
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.
You are given a string s. Check if the string is "s-palindrome".
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
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"); }}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Android ContentProvider
- matlab中NetCDF文件相关函数
- CMake学习总结
- 会开发和懂开发的区别
- <note>8月12日
- CodeForces
- 新型DDOS攻击防御至关重要
- sensor横纹和竖纹
- tensorflow3 mnist2
- java多线程入门之Thread实例
- java多线程总结五:线程池的原理及实现
- 非重复随机序列生成算法
- Mac设置安卓sdk环境变量
- Java项目中使用百度地图定位、导航开发