Created
February 3, 2014 10:02
-
-
Save KT-Yeh/8781266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
using namespace std; | |
char Mir[]="AAE3HHIIJLLJMMOOS2TTUUVVWWXXYYZ500112S3E5Z88"; | |
bool isMirrored (char a, char b){ | |
for (int i=0; Mir[i+1]; i++) | |
if (Mir[i]==a && Mir[i+1]==b) return 1; | |
return 0; | |
} | |
bool isPalindrome (char a,char b){ | |
return a == b; | |
} | |
int main() | |
{ | |
// freopen("input.txt","rt",stdin); | |
char c[100]; | |
while (gets(c)){ | |
bool palindrome = 1,mirrored = 1; | |
for (int i = 0, j = strlen(c)-1; i <= j; i++, j--){ | |
if (!isMirrored(c[i],c[j])) mirrored = 0; | |
if (!isPalindrome(c[i],c[j])) palindrome = 0; | |
} | |
if (palindrome && mirrored) printf("%s -- is a mirrored palindrome.\n\n",c); | |
else if (palindrome) printf("%s -- is a regular palindrome.\n\n",c); | |
else if (mirrored) printf("%s -- is a mirrored string.\n\n",c); | |
else printf("%s -- is not a palindrome.\n\n",c); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment