Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char charachter[21] = {'A','E','H','I','J','L','M','O','S','T','U','V','W','X','Y','Z','1','2','3','5','8'};
- char reverse_[21] = {'A','3','H','I','L','J','M','O','2','T','U','V','W','X','Y','5','1','S','E','Z','8'};
- int isPalindrome(char *str){
- int i, len = strlen(str);
- for(i = 0 ; i < len/2 ; i++)
- if(str[i] != str[len - i - 1])
- return 0;
- return 1;
- }
- int isMirrored(char *str){
- int indx1, indx2 ,i, len = strlen(str);
- for(i = 0 ; i < len/2; i++){
- indx1 = indx2 = 0;
- while(charachter[indx1] != str[i] && indx1 < 21)
- indx1++;
- while(reverse_[indx2] != str[len - i - 1] && indx2 < 21)
- indx2++;
- if(indx1 != indx2)
- return 0;
- }
- return 1;
- }
- int main()
- {
- char str[21];
- int x,y;
- while(scanf("%s",str)!= EOF ){
- x = isPalindrome(str);
- y = isMirrored(str);
- if(x == 0 && y == 0)
- printf("%s -- is not a palindrome.\n\n",str);
- else if(x==1 && y == 0)
- printf("%s -- is a regular palindrome.\n\n",str);
- else if(x == 0 && y == 1)
- printf("%s -- is a mirrored string.\n\n",str);
- else
- printf("%s -- is a mirrored palindrome.\n\n",str);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement