Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:你求second 的逻辑错误,second始终等于first-1。所以下面的for循环越界了。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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator