water problem.
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define MAX_CHAR 21
char con_digit[] = {
'1', 'S', 'E', '-', 'Z',
'-', '-', '8', '-'
};
char con_char[] = {
'A', '-', '-', '-', '3',
'-', '-', 'H', 'I', 'L',
'-', 'J', 'M', '-', 'O',
'-', '-', '-', '2', 'T',
'U', 'V', 'W', 'X', 'Y',
'5'
};
void conversion(const char *str, char *des)
{
for(int i = 0; '\0' != str[i]; i ++) {
if( isalpha(str[i]) ) {
des[i] = con_char[ str[i]-'A' ];
}
else if( isdigit(str[i]) ) {
des[i] = con_digit[ str[i]-'1' ];
}
}
des[strlen(str)] = '\0';
}
int is_palindrome(const char *str)
{
char tmp[MAX_CHAR];
for(int l = 0, r = strlen(str)-1; l < r; l ++, r --) {
if( str[l] != str[r] ) {
return 0;
}
}
return 1;
}
int is_mirror(const char *src, const char *des)
{
for(int i = 0, j = strlen(des)-1; j >= 0; i ++, j --) {
if( src[i] != des[j] ) {
return 0;
}
}
return 1;
}
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
freopen("test.in", "r", stdin);
#endif
char str[MAX_CHAR], conv_str[MAX_CHAR];
int flag_pal, flag_mirror;
while( ~scanf("%s", str) ) {
conversion(str, conv_str);
//printf("ori: %s, des:%s\n", str, conv_str);
flag_pal = is_palindrome(conv_str); flag_mirror = is_mirror(str, conv_str);
if( flag_pal && flag_mirror ) {
printf("%s -- is a mirrored palindrome.\n", str);
}
else if( flag_pal ) {
printf("%s -- is a regular palindrome.\n", str);
}
else if( flag_mirror ) {
printf("%s -- is a mirrored string.\n", str);
}
else {
printf("%s -- is not a palindrome.\n", str);
}
printf("\n");
}
return 0;
}