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

Re:help!!!查了半天还是wa阿!

Posted by nbatcg at 2007-10-24 14:26:45 on Problem 2092
In Reply To:help!!!查了半天还是wa阿! Posted by:llk at 2007-10-12 12:31:19
> #include<iostream>
> using namespace std;
> int main()
> {
> 	int n,m,i,j,count=0,second=0;
> 	int num;
> 	int a[10002]={0};
> 	while(scanf("%d%d",&n,&m))
> 	{
> 		if(n==0) return 0;
> 		for(i=0;i<n;i++)
> 		{
> 			for(j=0;j<m;j++)
> 			{
> 				scanf("%d",&num);
> 				a[num]++;
> 			}
> 		}
> 		for(i=1;i<10001;i++)
> 		{
> 			if(a[i]>count)
> 			{
> 				second=count;
> 				count=a[i];
> 			}
> 		}
> 		if(second==0)//如果第一个出现的a[i]就是最大的数
> 		{
> 			for(i=1;i<10001;i++)
> 			{
> 				if(a[i]!=0&&a[i]<count) second=a[i];
> 				if (a[i]<second) continue;
> 			}
> 		}
> 		
> 		for(i=1;i<=10000;i++)
> 		{
> 			if(a[i]==second) printf("%d ",i);
> 			a[i]=0;
> 		}
> 		
> 		count=0;second=0;
> 		printf("\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