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

怎么又是WA?

Posted by 36072219890803 at 2009-07-31 19:58:16 on Problem 2643
#include<stdio.h>
#include<string.h>
main()
{
	char cand[22][82],party[22][82],vote[10002][82];
	int n,m,a[20],max,pos,i,j,pos2,min;
	scanf("%d ",&n);
	memset(a,0,sizeof(a));	
	for(i=0;i<n;i++)
	{
		gets(cand[i]);
		gets(party[i]);
	}
	scanf("%d ",&m);
	for(i=0;i<m;i++)
	{
		gets(vote[i]);
		for(j=0;j<n;j++)
			if(strcmp(vote[i],cand[j])==0)
				a[j]++;
	}
	max=0;
	min=10000;
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
			pos=i;
		}
		if(a[i]<min)
		{
			min=a[i];
			pos2=i;
		}
	}
	if(max==min)
		printf("tie\n");
	else
		puts(party[pos]);
	
}


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