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 MasterLuo at 2008-04-23 20:33:41 on Problem 2092
#include <iostream>
using namespace std;
int main()
{
	int m, n;
	cin>>m>>n;
	while((m!=0) && (n!=0))
	{
		int players[10001];
		for(int i=0; i<10001; i++)
				players[i]=0;
		int temp;
		int max=-1, sec=-1;
		for(int i=0; i<m; i++)
		    for(int j=0; j<n; j++)
			{
				cin>>temp;
				players[temp]++;
				if(players[temp]>max)
				{
					sec=max;
					max=players[temp];
				}else if(players[temp]<max && players[temp]>sec)
				{
					sec=players[temp];
				}
			}

		for(int i=1; i<=10000; i++)
		    if(players[i]==sec)
		        cout<<i<<" ";

		cout<<endl;
		cin>>m>>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