<span style="font-size:18px;">#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;
const char* a="A 3 HIL JM O 2TUVWXY51SE Z 8 ";
const char* b[]={" -- is not a palindrome."," -- is a regular palindrome."," -- is a mirrored string."," -- is a mirrored palindrome."};
char change(char s)
{
if(isalpha(s))return a[s-'A'];
return a[s-'0'+25];
}
int main()
{
char str[21];
while(scanf("%s",str)!=EOF)
{
int len=strlen(str),p=1,q=1;
for(int i=0;i<(len+1)/2;i++)
{
if(str[i]!=str[len-i-1])p=0;
if(change(str[i])!=str[len-i-1])q=0;
}
printf("%s%s\n\n",str,b[p+q*2]);
}
return 0;
}
</span>
isalpha:判断字符是否为英文字符,若为小写返回2,大写返回1,不是字母返回0.
isdigit:判断字符是否为数字0~9,是,返回TRUE,否则,返回NULL(0)。
输出使用的数组注意
注意下判断是否为镜像串的方法。。