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 yanchao at 2007-08-16 16:49:26
#include<stdio.h>
#define N 2500
int main()
{
	int n,m,a[501][501],b[N],c[N],d[N],i,j,k,w,done;
	while(1)
	{
		scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;
		for(i=0;i<n;i++)
			for(j=0;j<m;j++)
			{
				scanf("%d",&a[i][j]);
			}
			k=0;
			b[k]=-1;
			c[k]=-1;
		for(i=0;i<n;i++)
			for(j=0;j<m;j++)
			{
				for(w=0;w<=k;w++)
					if(a[i][j]==c[w])
					{
						b[w]+=1;
						break;
					}
				if(w==k+1)
				{
					k++;
					c[k]=a[i][j];
					b[k]=1;
				}
			}
	//		for(i=1;i<=k;i++)
	//			printf("(%d %d) ",c[i],b[i]);
			w=1;
			done=1;
			while(done&&w<=k)
			{
				done=0;
				for(i=1;i<k;i++)
                   if(b[i]<b[i+1])
				   {
					   b[0]=b[i];
					   b[i]=b[i+1];
					   b[i+1]=b[0];
					   c[0]=c[i];
					   c[i]=c[i+1];
					   c[i+1]=c[0];
					   done=1;
				   }
				   w++;
			}
			w=0;
			for(i=2;i<=k;i++)
				if(b[i]==b[2])
				{
					w++;
					d[w]=c[i];					
				}
			j=1;
			done=1;
			while(done&&j<=w)
			{
				done=0;
				for(i=1;i<w;i++)
                   if(d[i]>d[i+1])
				   {
					   d[0]=d[i];
					   d[i]=d[i+1];
					   d[i+1]=d[0];
					   done=1;
				   }
				   j++;
			}
			for(i=1;i<=w;i++)
				printf("%d ",d[i]);
				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