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:你求second 的逻辑错误,second始终等于first-1。所以下面的for循环越界了。

Posted by yao503 at 2007-12-03 10:21:07 on Problem 2092
In Reply To:机上运行没问题但为什么是运行错误。。。。。 Posted by:Go_always at 2007-11-16 08:54:39
> 运行错误时怎么办啊?求大牛们讲下心得。。。谢谢
> #include<stdio.h>
> int main()
> {
> 	int i,j,x,n,m,first,second,point[10001];
> 	while(1)
> 	{
> 		scanf("%d%d",&n,&m);
> 		if(n==0&&m==0)break;
> 		for(i=0;i<10001;i++)
> 			point[i]=0;
> 		first=0;
> 		second=0;
> 		for(i=0;i<n*m;i++)
> 		{
> 			scanf("%d",&x);
> 			point[x]++;
> 			if(point[x]>first)
> 			{
> 				second=first;
> 				first=point[x];
> 			}
> 		}
> 		for(j=10000;;j--)
> 			if(point[j]==second)break;
> 		for(i=1;i<j;i++)
> 			if(point[i]==second)
> 				printf("%d ",i);
> 		printf("%d\n",j);
> 	}
> 	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