Sample Input
NOTAPALINDROME
ISAPALINILAPASI
2A3MEAS
ATOYOTA
Sample Output
NOTAPALINDROME -- is not a palindrome.
ISAPALINILAPASI -- is a regular palindrome.
2A3MEAS -- is a mirrored string.
ATOYOTA -- is a mirrored palindrome.
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char r(char ch)
{
char jingxiang[]="A 3 HIL JM O 2TUVWXY51SE Z 8 ";
if(isalpha(ch))
return jingxiang[ch-'A'];
return jingxiang[ch-'0'+25];
}
int main ()
{
char c[30];
int len, p, m, i;
while (scanf("%s",c)!=EOF)
{
char d[30];
len=strlen(c);
p=m=1;
for(i=0;i<len;i++)
{
if(c[i]!=c[len-1-i]) p=0;
if(r(c[i])!=c[len-1-i]) m=0;
}
if(m==0&&p==0) strcpy(d, "not a palindrome");
else if(m==0&&p==1) strcpy(d, "a regular palindrome");
else if(m==1&&p==0) strcpy(d, "a mirrored string");
else strcpy(d, "a mirrored palindrome");
printf("%s -- is %s.\n\n", c, d);
}
return 0;
}