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 |
看了很久,很长时间,想不明白哪里出错了??哪位大哥帮忙调试一下。。。谢谢#include<stdio.h> void main() { int m[100001],i,n,sum,b,x[100001],y[100001]; while(1) { scanf("%d",&n); if(n==0) break; for(i=1;i<=n;i++) scanf("%d",&m[i]); sum=0; b=0; for(i=1;i<n;i++) { if(b>0) b+=m[i]; else b=m[i]; if(b>sum) sum=b; x[i]=sum; } sum=0; b=0; for(i=n;i>1;i--) { if(b>0) b+=m[i]; else b=m[i]; if(b>sum) sum=b; y[i]=sum; } sum=x[1]+y[2]; for(i=2;i<n;i++) if((x[i]+y[i+1])>sum) sum=x[i]+y[i+1]; printf("%d\n",sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator