题目链接:https://odzkskevi.qnssl.com/9b33ac42e5fbc32e8c88307566611887?v=1510093739
My ugly code
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
map<char,char> mp;
string s;
void INIT(){
mp['A']='A';
mp['E']='3';
mp['H']='H';
mp['I']='I';
mp['J']='L';
mp['L']='J';
mp['M']='M';
mp['O']='O';
mp['S']='2';
mp['T']='T';
mp['U']='U';
mp['V']='V';
mp['W']='W';
mp['X']='X';
mp['Y']='Y';
mp['Z']='5';
mp['1']='1';
mp['2']='S';
mp['3']='E';
mp['5']='Z';
mp['8']='8';
}
int main(){
INIT();
while(getline(cin,s)){
int flag1=1,flag2=1;
int len=s.length();
for(int i=0;i<(len)/2;i++){
if(s[i] != s[len-i-1]){
flag1=0;
break ;
}
}
for(int i=0;i<(len+1)/2;i++){
if(mp[ s[i] ] == NULL || mp[ s[i] ] !=s[len-i-1] ){
flag2=0;
break ;
}
}
cout << s ;
if(flag1==0 && flag2 ==0){
printf(" -- is not a palindrome.\n\n");
continue ;
}
if(flag1==1 && flag2==0){
printf(" -- is a regular palindrome.\n\n");
continue ;
}
if(flag1==0 && flag2==1){
printf(" -- is a mirrored string.\n\n");
continue ;
}
if(flag1==1 && flag2==1){
printf(" -- is a mirrored palindrome.\n\n");
continue ;
}
}
return 0;
}