zoukankan      html  css  js  c++  java
  • Codeforces 691B. s-palindrome

    题目链接: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 }
  • 相关阅读:
    docker生态系统
    访问远程的docker
    docker实践4
    docker实践3
    docker实践
    Spark快速入门
    shuffle和sort分析
    hadoop原理
    apacheds的客户端
    LDAP apacheds解决方案
  • 原文地址:https://www.cnblogs.com/Ash-ly/p/5837394.html
Copyright © 2011-2022 走看看