1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0);
map<char, char> m = {{'A', 'A'}, {'E', '3'}, {'H', 'H'}, {'I', 'I'}, {'J', 'L'}, {'L', 'J'}, {'M', 'M'}, {'O', 'O'}, {'S', '2'}, {'T', 'T'}, {'U', 'U'}, {'V', 'V'}, {'W', 'W'}, {'X', 'X'}, {'Y', 'Y'}, {'Z', '5'}, {'1', '1'}, {'2', 'S'}, {'3', 'E'}, {'5', 'Z'}, {'8', '8'}};
string text; while(getline(cin, text)){ bool isPalin = false, isMirror = false; string palin = text; reverse(palin.begin(), palin.end()); if(palin == text) isPalin = true; string mirror = text; for(int i=0; i<mirror.length(); ++i){ if(m.count(mirror[i])) mirror[i] = m[mirror[i]]; else mirror[i] = '?'; } reverse(mirror.begin(), mirror.end()); if(mirror == text) isMirror = true;
cout << text; if(isPalin && isMirror) cout << " -- is a mirrored palindrome."; else if(isPalin) cout << " -- is a regular palindrome."; else if(isMirror) cout << " -- is a mirrored string."; else cout << " -- is not a palindrome."; cout << "\n\n"; }
return 0; }
|