Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
坑题#include <iostream> #include <stdio.h> #include <string.h> using namespace std; bool isP(char *str, int len){ for(int i = 0; i < len/2; i++){ if(str[i] != str[len-1-i]) return false; } return true; } char mr(char c){ switch(c){ case 'A': case 'H': case 'I': case 'M': case 'O': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case '1': case '8': return c; case 'E': return '3'; case '3': return 'E'; case 'J': return 'L'; case 'L': return 'J'; case 'S': return '2'; case '2': return 'S'; case 'Z': return '5'; case '5': return 'Z'; default: return '\0'; } } bool isM(char *str, int len){ for(int i = 0; i < (len+1)/2; i++){ if(mr(str[i]) != str[len-1-i]) return false; } return true; } char desc[4][233] = {"not a palindrome", "a regular palindrome", "a mirrored string", "a mirrored palindrome"}; int main() { char str[233]; while(scanf("%s", str) == 1){ int len = strlen(str); int isp = isP(str, len), ism = isM(str, len); int idx = isp + 2 * ism; printf("%s -- is %s.\n\n", str, desc[idx]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator