-
Notifications
You must be signed in to change notification settings - Fork 5
/
UVA-401.cpp
70 lines (63 loc) · 1.17 KB
/
UVA-401.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
char s[25], s2[25];
bool palin(char * s) {
int i, len = strlen(s);
for(i=0; i<len/2; ++i)
if(s[i] != s[len-i-1])
return false;
return true;
}
map<char,char> mp;
bool mirror(char * s) {
int len = strlen(s);
for(int i=0; i<=len/2; ++i)
if(mp.find(s[i]) == mp.end() || mp[s[i]] != s[len-i-1])
return false;
return true;
}
void addmp() {
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() {
int i,j,k;
bool mir, pal;
addmp();
while(scanf("%s", s) == 1) {
strcpy(s2, s);
pal = palin(s);
mir = mirror(s);
if(mir && pal)
printf("%s -- is a mirrored palindrome.\n", s2);
if(!mir && pal)
printf("%s -- is a regular palindrome.\n", s2);
if(mir && !pal)
printf("%s -- is a mirrored string.\n", s2);
if(!mir && !pal)
printf("%s -- is not a palindrome.\n", s2);
puts("");
}
return 0;
}