Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why?

Posted by q249281713 at 2009-03-06 16:45:59
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator