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:请问为什么出现Output Limit Exceed?谢谢诸位!!!!

Posted by tcxgsy at 2005-08-09 14:31:02 on Problem 2452
In Reply To:Re:请问为什么出现Output Limit Exceed?谢谢诸位!!!! Posted by:mostleg at 2005-08-09 10:06:44
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^为什么要循环3次?
#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:
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