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

chengxu

Posted by wcp at 2005-07-20 15:07:04 on Problem 2503
In Reply To:我用文件结束怎么 超时阿!!!!!!!!!!!! Posted by:wcp at 2005-07-20 14:49:31
#include "stdio.h"
#include "ctype.h"
#include "string.h"


int main()
{
	char s[1000][10]={'\0'},ss[1000][10]={'\0'},s1[22]={'\0'};
	int i,j,k,flag;
    i=0;j=0;
	while(1)
	{   
       gets(s1);flag=0;j=0;
	   if(strcmp(s1,"\0")==0) break;
	   for(k=0;k<20;k++)
	   {
		   if(s1[k]==' ')
		   {
			   flag=1;j=0;
			   continue;
		   }
		   if(flag==0) s[i][j++]=s1[k];
		   if(flag==1) ss[i][j++]=s1[k];
	   }
	   i++;
	}
	while(scanf("%s",s1)!=EOF)
	{
		flag=0;
		for(j=0;j<i;j++)
		{
			if(strcmp(s1,ss[j])==0) 
			{
				printf("%s\n",s[j]);
				flag=1;
			}
			if(flag==1)   break;
		}
		if(flag==0)    printf("eh\n");
	}
	return 1;
}





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