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 ACM05002 at 2005-08-16 15:11:15 on Problem 2452
In Reply To:我写成这样,怎么还是WA?请你们帮我看看 Posted by:tcxgsy at 2005-08-16 13:40:56
大哥你错成这样了还敢贴上来呀???

> #define  M  50001
> #include"stdio.h"
> #include"math.h"
> 
> long com(long a[],long n)
> { int i, temp_max, temp_min, max, min;
>     temp_max = temp_min = a[0];
>     max = min = 0;
>     for(i=1;i<n;i++) {
>         if(a[i] > temp_max){
>              temp_max = a[i];
>             max = i;
>         }
>         if(a[i] < temp_min){
>             temp_min = a[i];
>             min = i;
>         }
>     }
>     if(max>min)  return(max-min);
>         else  return(-1);
> }
>  int main()
> {
> 	long n,max;
> 	long i,j;
>           long a[M];
> 	while (scanf("%ld",&n)==1)
> 	{
> 		j=0;
> 		max=0;
> 		for (i=0;i<n;i++)
> 		{
> 			scanf("%ld",&a[i]);
> 		}
> 		max=com(a,n);
> 		printf("%ld\n",max);
> 	}
> 
> 
> 	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