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 HIT_Happy at 2010-01-07 10:01:13 on Problem 2608
#include <iostream>
using namespace std;
//2656
char convert(char ch);
int main(void){
	
	char a[64];
	int i,len,num;
	
	while(a[0] = cin.get())
	{	
		a[0] = convert(a[0]);
		for(i = 1;i<64;i++)
		{
			a[i] = cin.get();
			if(a[i] == '\n')
				break;
			a[i] = convert(a[i]);
		}
		len = i;		
		num = 0;
		for(i = 0;i<len;i++)
		{
			if(a[i] == a[i+1])
				a[i] = '*';
			if(a[i] != '*')
			{
				cout<<a[i];
				num++;
			}
		}		
		if(num!=0)
			cout<<endl;
	}
	return 0;
}
char convert(char ch)
{
	if(ch=='B'||ch=='F'||ch=='P'||ch=='V')	
		ch = '1';
	else if(ch=='C'||ch=='G'||ch=='J'||ch=='K'||ch=='Q'||ch=='S'||ch=='X'||ch=='Z')
		ch = '2';
	else if (ch == 'D'||ch == 'T')
		ch = '3';
	else if(ch == 'L')
		ch = '4';
	else if(ch == 'M'||ch == 'N')
		ch = '5';
	else if(ch == 'R')
		ch = '6';
	else
		ch = '*';
	return ch;
}

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