Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char cmp[1024];
- int N;
- char getReverse(char c){
- switch(c){
- case 'A': return 'A';
- case 'E': return '3';
- case 'H': return 'H';
- case 'I': return 'I';
- case 'J': return 'L';
- case 'L': return 'J';
- case 'M': return 'M';
- case 'O': return 'O';
- case 'S': return '2';
- case 'T': return 'T';
- case 'U': return 'U';
- case 'V': return 'V';
- case 'W': return 'W';
- case 'X': return 'X';
- case 'Y': return 'Y';
- case '5': return 'Z';
- case 'Z': return '5';
- case '1': return '1';
- case '2': return 'S';
- case '3': return 'E';
- case '8': return '8';
- default: return '\n';
- }
- }
- bool isPalindrome(void){
- for(int i(0),j(N-1);i<j;++i,--j)
- if(cmp[i]!=cmp[j])
- return false;
- return true;
- }
- bool isReverse(void){
- for(int i(0),j(N-1);i<=j;++i,--j)
- if(cmp[i]!=getReverse(cmp[j]))
- return false;
- return true;
- }
- int main(void){
- while(scanf("%s",cmp)==1){
- printf("%s",cmp);
- N=strlen(cmp);
- if(isPalindrome())
- if(isReverse())
- printf(" -- is a mirrored palindrome.\n\n");
- else
- printf(" -- is a regular palindrome.\n\n");
- else
- if(isReverse())
- printf(" -- is a mirrored string.\n\n");
- else
- printf(" -- is not a palindrome.\n\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement