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 fjnu_jxd_010 at 2005-07-20 23:29:36 on Problem 2503
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i=0,j,n,flag;
	char c[100];
	string a[100009],b[100009];

	while(1)
	{
		
		
		i++;
		gets(c);
		if(c[0]=='\0')
			break;
		a[i]=c;
		for(j=0;j<=a[i].length();j++)
			if(a[i][j]==' ')
			{
				b[i]=a[i].substr(j+1);
			a[i]=a[i].substr(0,j);
			break;
			}


	}
	
	n=i-1;
	
	while(scanf("%s",c)!=EOF)
	{
				flag=0;
		for(j=1;j<=n;j++)
		{
			//cout<<c;
			if(b[j]==c)
			{
				flag=1;
				printf("%s\n",&a[j][0]);
				break;
			}
		}
		if(flag==0)
			printf("eh\n");

	}

	
	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