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:我的c 代码In Reply To:我的c 代码 Posted by:gardner at 2005-10-09 02:30:25 > #include <stdio.h> int input[100001]; > void main() > { > > int left[100001],right[100001]; > long num,sum,i,flag,max; > scanf("%d",&num); > while(num!=0){ > for(i=0;i<num;i++)scanf("%d",&input[i]); > sum=0; > flag=input[0]; > for(i=0;i<num;i++){ > if(sum>=0)sum+=input[i]; > else sum=input[i]; > if(flag<sum)flag=sum; > left[i]=flag; > } > sum=0; > flag=input[num-1]; > for(i=num-1;i>=0;i--){ > if(sum>=0)sum+=input[i]; > else sum=input[i]; > if(flag<sum)flag=sum; > right[i]=flag; > } > max=left[0]+right[1]; > for(i=0;i<num-1;i++){ > if(left[i]+right[i+1]>max)max=left[i]+right[i+1]; > } > printf("%d\n",max); > scanf("%d",&num); > } > } 刚刚发错了 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator