-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUVA00401.cpp
52 lines (49 loc) · 1.28 KB
/
UVA00401.cpp
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
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>
using namespace std;
bool reverse(char a, char b) {
switch (a) {
case 'A': return b == 'A';
case 'E': return b == '3';
case 'H': return b == 'H';
case 'I': return b == 'I';
case 'J': return b == 'L';
case 'L': return b == 'J';
case 'M': return b == 'M';
case 'O': return b == 'O';
case 'S': return b == '2';
case 'T': return b == 'T';
case 'U': return b == 'U';
case 'V': return b == 'V';
case 'W': return b == 'W';
case 'X': return b == 'X';
case 'Y': return b == 'Y';
case 'Z': return b == '5';
case '1': return b == '1';
case '2': return b == 'S';
case '3': return b == 'E';
case '5': return b == 'Z';
case '8': return b == '8';
default: return false;
}
}
void proc(string & word, bool & pal, bool & mir) {
for (int i = 0, j = word.length() - 1; i <= j; i++, j--) {
if (word[i] != word[j]) pal = false;
if (!reverse(word[i], word[j])) mir = false;
}
}
int main() {
string word;
while (cin >> word) {
bool pal = true, mir = true;
proc(word, pal, mir);
cout << word << " -- ";
if(pal && mir) cout << "is a mirrored palindrome.";
else if(mir) cout << "is a mirrored string.";
else if(pal) cout << "is a regular palindrome.";
else cout << "is not a palindrome.";
cout << endl << endl;
}
return 0;
}