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

哪错了?

Posted by 871197396 at 2009-09-03 18:57:30
#include <iostream>
using namespace std;

char convert(char c);
int main(void)
{
	char ch[100];
	int len;
	while(cin>>ch)
	{
		len=strlen(ch);
		for(int i=0;i<len;i++)
		{
			if(i-1>=0)
			{
				if(ch[i]==ch[i-1])
					ch[i-1]=' ';
			}
		}
			for(int j=0;j<len;j++)
				for(int k=j+1;k<len;k++)
				{
					if(convert(ch[j])==convert(ch[k]))
						ch[k]=' ';
				}
			for(int l=0;l<len;l++)
			{
				if(convert(ch[l])!=' ')
				cout<<convert(ch[l]);
				if(l==len-1)
					cout<<endl;
			}
	}
	return 0;
}

char convert(char c)
{
	if(c=='B'||c=='F'||c=='P'||c=='V')
		return '1';
	if(c=='C'||c=='G'||c=='J'||c=='K'||c=='Q'||c=='S'||c=='X'||c=='Z')
		return '2';
	if(c=='D'||c=='T')
		return '3';
	if(c=='L')
		return '4';
	if(c=='M'||c=='N')
		return '5';
	if(c=='R')
		return '6';
	return ' ';
}

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