首页 > 其他 > 详细

Codeforces 691B. s-palindrome

时间:2016-09-03 18:00:37      阅读:207      评论:0      收藏:0      [点我收藏+]

题目链接:http://codeforces.com/problemset/problem/691/B

题意:

给你一个字符串,需要让你判断这个字符串是否为镜像串,即关于中心轴对称.

思路:

常量数组的运用,需要注意的是当字符串包含奇数个字符时最中间的那个字符不要忘记判断.

代码:

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const int MAXN = 100000;
 6 typedef long long LL;
 7 
 8 char str[] = "-d-b----------oqp----vwx--A------HI---M-O----TUVWXY-";
 9 
10 char chage(char c) {
11     if(islower(c)) return str[c - a];
12     return str[c - A + 26];
13 }
14 
15 int main() {
16     ios_base::sync_with_stdio(0); cin.tie(0);
17     char ss[1007] = {0};
18     cin >> ss;
19     int len = strlen(ss);
20     int ok = 1;
21     for(int i = 0; i < (len + 1) / 2; i++) if(ss[i] != chage(ss[len - i - 1])) ok = 0;
22     if(ok) cout << "TAK" << endl;
23     else cout << "NIE" << endl;
24     return 0;
25 }

 

Codeforces 691B. s-palindrome

原文:http://www.cnblogs.com/Ash-ly/p/5837394.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!