根据以下最大子序列求和的程序文件,画出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图。
分 -->
|