标题:[求助],有重谢
只看楼主
xjlsgcjdtc
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-9-4
得分:0 
int maxsubsum(int a,int left,int right)
{
int sum=0;
if(left==right)sum=a[align=left]>0 ? a[align=left]:0;
else{
int center=(left+right)/2;
int leftsum=maxsubsum(a,left,center);
int rightsum=maxsubsum(a,center+1,right);
int s1=0,left=0;
for(int i=center;i>=left;i--){
left+=a[i];
if(lefts>s1)s1=lefts;
}
int s2=0,rights=0;
for(int i=center+1;i<=right;i++){
rights+=a[i];
if(lefts>s2)s2=rights;
}
sum=s1+s2;
if(sum<leftsum) sum=leftsum;
if(sum<rightsum) sum=rightsum;
}
return sum;
}



String me = "program"
2007-09-05 15:34
论坛元老
Rank: 1
等 级:新手上路
帖 子:812
专家分:0
注 册:2008-3-31
得分:0 
路过,顶一下
2008-04-02 14:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-166792-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.490360 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved