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 shiming413 at 2005-10-13 13:50:08 on Problem 2643
In Reply To:WA了。。。。怎么回事 Posted by:adamgic at 2005-10-13 12:51:11
#include <stdio.h>
#include <string.h>
struct item
{
	char par[80];
	char can[80];
	int l;
};
void main()
{
	int n,m,i,j;
	char ch[80];
	scanf("%d\n",&n);
	item *p=new item[n];
	for(i=0;i<n;i++)
	{
		gets(p[i].can);
		gets(p[i].par);
		p[i].l=0;
	}
	scanf("%d\n",&m);
	for(i=0;i<m;i++)
	{
		gets(ch);
		for(j=0;j<n;j++)
			if(strcmp(ch,p[j].can)==0)
			{
				p[j].l++;
				break;
			}
	}
	int counter=0,max=0,k;
	for(i=0;i<n;i++)
	{
		if(p[i].l>max)
		{
			counter=1;
			max=p[i].l;
			k=i;
			continue;
		}
		if(p[i].l==max)
			counter++;
	}
	if(counter!=1)
		printf("%s\n","tie");
	else
		printf("%s\n",p[k].par);
}

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