Test instructions: Input string, judging palindrome and mirror
Analysis: Playing table, comparison, marker variable judgment
NOTES: Water problem, attention to detail, note output format!!!!!!!!!!!!!!!
1 //#define LOCAL2#include"Cstdio"3#include"CString"4#include"Cctype"5 using namespacestd;6 Const intmaxn= -;7 Chars1[maxn],s[]="A 3 HIL JM O 2tuvwxy51se Z 8";8 BOOLPal,mir;9 CharRCharc)Ten { One if(Isalpha (c))returns[c-'A']; A returns[c-'0'+ -]; - } - voidprint () the { - if(Pal&&mir) printf ("%s--is a mirrored palindrome.\n\n", S1); - if(!pal&&mir) printf ("%s--is a mirrored string.\n\n", S1); - if(Pal&&!mir) printf ("%s--is a regular palindrome.\n\n", S1); + if(!pal&&!mir) printf ("%s--is not a palindrome.\n\n", S1); - } + intMain () A { at #ifdef LOCAL -Freopen ("In.txt","R", stdin); -Freopen ("OUT.txt","W", stdout); - #endif //LOCAL - while(SCANF ("%s", s1)! =EOF) - { in intLen=strlen (S1);p al=true; mir=true; - for(intI=0;i< (len+1)/2; i++) to { + if(s1[i]!=s1[len-1-i]) pal=false; - if(R (S1[i])!=s1[len-1-i]) mir=false; the } * print (); $ }Panax Notoginseng return 0; -}
UVA 401-palindromes