最大子序列求和的N

[复制链接]
查看11 | 回复1 | 2021-1-27 05:04:53 | 显示全部楼层 |阅读模式
根据以下最大子序列求和的程序文件,画出N-S图和程序流程图。
PrivatestaticintmaxSumRec(int[]a,intleft,intright){
if(left==right)
if(a[left]>0){
returna[left];
}else{
return0;
}
intcenter=(left+right)/2;
intmaxLeftSum=maxSumRec(a,left,center);
intmaxRightSum=maxSumRec(a,center+1,right);
intmaxLeftBorderSum=0,leftBorderSum=0;
for(inti=center;i>=left;i--)
{
leftBorderSum+=a;
if(leftBorderSum>maxLeftBorderSum){
maxLeftBorderSum=leftBorderSum;
}
}
intmaxRightBorderSum=0,rightBorderSum=0;
for(inti=center+1;imaxRightBorderSum){
maxRightBorderSum=rightBorderSum;
}
}
returnmax(maxLeftSum,maxRightSum,maxLeftBorderSum+maxRightBorderSum);
}
要求:实验结果中列出所需的程序流程图和N-S图。

分 -->
回复

使用道具 举报

千问 | 2021-1-27 05:04:53 | 显示全部楼层

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行