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 sunmoonstar_love at 2005-08-24 16:05:41
In Reply To:帮帮忙吧,谢谢! Posted by:tiantian at 2005-08-24 15:22:17
> 请高手不吝赐教
> 以下是我的一个程序,不知为什么,第一次比较时,max=i;没有执行;请问谁能帮我解答一下,谢谢!
> main()
> { long int a[500];
>   int i=1,n,max=0,k=0,h=0,min=0,j=0;
> 
>   printf("input :");
>   scanf("%d",&n);
> 
> for(j=0;j<n;j++)
>     scanf("%d",&a[j]);
>   for(i=1,max=0,min=0;i<n;)
>   {if(a[max]<a[i]) max=i;printf( "   %d  ",i);
>   if(a[max]<a[i]) { max=i; }
> 	printf("%d\n",max);
>      if(a[min]>=a[i]||i==n-1)  {
>        h=max-min;
> 	min=max+1;
>       max++;
>       if(h>k) k=h;
>     if(i==n-1) break;
> 
> 	else i=min;
>     }
>      i++;
>     }
>     if(k>0) printf("%d\n",k);
>     else printf("-1");
>     }

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