对称串和回文串
1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 using namespace std; 5 const char s1[30]={'A',0,0,0,'3',0,0,'H','I','L',0,'J','M',0,'O',0,0,0,'2','T','U','V','W','X','Y','Z'}; 6 const char s2[30]={'1','S','E',0,'Z',0,0,'8',0}; 7 char s[100]; 8 int len; 9 bool fr,fp; 10 int main() 11 { 12 while(~scanf("%s",&s)){ 13 len=strlen(s); 14 fr=fp=1; 15 for(int i=0;i<=len/2;i++){ 16 if(s[i]!=s[len-i-1]) fp=0; 17 if('0'<=s[i]&&s[i]<='9'){ 18 if(s2[s[i]-'1']!=s[len-i-1]) fr=0; 19 } else { 20 if(s1[s[i]-'A']!=s[len-i-1]) fr=0; 21 } 22 } 23 if(fr&&fp){ 24 printf("%s -- is a mirrored palindrome. ",s); 25 } else if(fr){ 26 printf("%s -- is a mirrored string. ",s); 27 } else if(fp){ 28 printf("%s -- is a regular palindrome. ",s); 29 } else { 30 printf("%s -- is not a palindrome. ",s); 31 } 32 puts(""); 33 } return 0; 34 }