【鬼畜】UVA

管他什么rev数组,msg数组简化代码

#define _CRT_SECURE_NO_WARNINGS
#include    <cmath>
#include <iostream>
#include    <stdio.h>
#include<algorithm>
#include        <map>
#include     <cstring>
#include      <time.h>
#include      <string>
using namespace std;
#define rep(i,t,n)  for(int i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
const int maxn = 20 + 5;
const long long mod = 1e9 + 7;
int n; int sum = 0;
int a[maxn]; int vis[maxn];
bool cmp(int a, int b) { return a > b; }
char M[256];


bool mirror(string s) {
    int len = s.length();
    rep(i, 0, len - 1) {
        if (s[i] != M[s[len-1 - i]])return 0;
    }
    return 1;
}
bool palin(string s) {
    int len = s.length();
    rep(i, 0, len - 1) {
        if (s[i] != s[len-1 - i])return 0;
    }
    return 1;
}

int main() {    
    M['A'] = 'A'; M['E'] = '3'; M['M'] = 'M'; M['O'] = 'O'; M['S'] = '2'; M['T'] = 'T'; M['U'] = 'U'; M['V'] = 'V'; M['W'] = 'W'; M['X'] = 'X'; M['Y'] = 'Y'; M['Z'] = '5'; M['1'] = '1'; M['2'] = 'S'; M['3'] = 'E'; M['5'] = 'Z'; M['8'] = '8'; M['L'] = 'J';    M['J'] = 'L'; M['I'] = 'I'; M['H'] = 'H';
    string ss;
    
    while (cin>>ss) {
        int f1 = 0, f2 = 0;
        if (mirror(ss))f1 = 1;
        if (palin(ss))f2 = 1;
        cout << ss;
        if (f1&&f2)puts(" -- is a mirrored palindrome.");
        else if (f1 && !f2)puts(" -- is a mirrored string.");
        else if (!f1&&f2)puts(" -- is a regular palindrome.");
        else puts(" -- is not a palindrome.");
        cout << endl;
    }
    

    //cin >> n;
}

/*
3
4 1 1 1 1
5 10 20 30 40 50
8 1 7 2 6 4 4 3 5

1
3
1 1 2
A    A    M    M    Y    Y
B         N         Z    5
C         O    O    1    1
D         P         2    S
E    3    Q         3    E
F         R         4
G         S    2    5    Z
H    H    T    T    6
I    I    U    U    7
J    L    V    V    8    8
K         W    W    9
L    J    X    X
*/
成功的路并不拥挤,因为大部分人都在颓(笑)
原文地址:https://www.cnblogs.com/SuuT/p/9416365.html