#include<bits/stdc++.h>
using namespace std;
const char rev[]= "A 3 HIL JM O 2TUVWXY51SE Z 8 ";
const string ans[]= {"is not a palindrome.", "is a regular palindrome.", "is a mirrored string.", "is a mirrored palindrome."};
char Reverse(char st)
{
if(isalpha(st)) return rev[st-'A'];
else return rev[st-'0'+25];
}
int main()
{
string st;
while(cin>>st)
{
int pal=1,mir=1;
int l=st.length();
for(int i=0; i<(l+1)/2; i++)
if(st[i]!=st[l-i-1])
{
pal=0;
break;
}
for(int i=0; i<(l+1)/2; i++)
if(Reverse(st[i])!=st[l-i-1])
{
mir=0;
break;
}
cout<<st<<" -- "<<ans[mir*2+pal]<<"\n"<<endl;
}
return 0;
}
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=342
UVA 401(p48)----Palindromes
最新推荐文章于 2022-08-21 17:52:04 发布