| ||||||||||
| 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 | |||||||||
why?#include<iostream>
#include<string>
using namespace std;
char change(char a)
{
if (a=='A') return 'A';
else if (a=='E') return '3';
else if (a=='H') return 'H';
else if (a=='I') return 'I';
else if (a=='J') return 'L';
else if (a=='L') return 'J';
else if (a=='M') return 'M';
else if (a=='O') return 'O';
else if (a=='S') return '2';
else if (a=='T') return 'T';
else if (a=='U') return 'U';
else if (a=='V') return 'V';
else if (a=='W') return 'W';
else if (a=='X') return 'X';
else if (a=='Y') return 'Y';
else if (a=='Z') return '5';
else if (a=='1') return '1';
else if (a=='2') return 'S';
else if (a=='3') return 'E';
else if (a=='5') return 'Z';
else if (a=='8') return '8';
else return '#';
}
int main(void)
{
string a;
while(cin>>a/*getline(cin,a,'\n')*///getline就是错误的,不知道为什么……)
{int l,i=0;
l=a.length();
bool p=true;
bool m=true;
int middle=l/2+1;
for(;i<middle;i++)
{
if(!(a[i]==a[l-i-1]))
{
p=false;
break;
}
}
for(i=0;i<middle;i++)
{
if(!(a[l-i-1]==change(a[i])))
{
m=false;
break;
}
}
if(p)
{
if(m)
cout<<a<<" -- is a mirrored palindrome."<<endl<<endl;
else
cout<<a<<" -- is a regular palindrome."<<endl<<endl;
}
else
{
if(m)
cout<<a<<" -- is a mirrored string."<<endl<<endl;
else
cout<<a<<" -- is not a palindrome."<<endl<<endl;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator