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 |
这个是我在online contest 做出的第一题,那次一下就作出两个,纯模,向两个方向延伸In Reply To:Re:请问为什么出现Output Limit Exceed?谢谢诸位!!!! Posted by:tcxgsy at 2005-08-09 14:31:02 > #define M 1024 > #include"stdio.h" > #include"math.h" > > int Max(int a[M],int n) > { int i,j=0; > int max; > for(i=0;i<n;i++) > for(j=0;j<n;j++) > { if(a[i]>=a[j]) > max=i; > else continue; > } > return(i+1); > } > int Min(int a[M],int n) > { > int i,j=0; > int min; > for(i=0;i<n;i++) > for(j=0;j<n;j++) > {if(a[i]<=a[j]) > { > min=i; > } > else continue; > } > return(j+1); > } > main() > {int i,n; > int a[M],b[M]; > int k,l,j; > for(j=0;j<3;j++) //不是要多组测试数据吗? > { scanf("%d",&n); > while(n>0&&n<=5000) //我这是不是应该改成if > { for(i=0;i<n;i++) > { scanf("%d",&a[i]); } > k=Max(a,n); > l=Min(a,n); > if(k>l) > printf("%d\n",k-l); > else printf("-1\n"); > scanf("%d",&n); > } } > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator