int MaxSubSum(int *arr,int len)
{
int i;
int MaxSum = 0;
int CurSum = 0;
for(i=0;i
{
CurSum += arr[i];
if(CurSum > MaxSum)
MaxSum = CurSum;
//如果累加和出现小于0的情况,
//则和最大的子序列肯定不可能包含前面的元素,
//这时将累加和置0,从下个元素重新开始累加
if(CurSum < 0)
CurSum = 0;
}
return MaxSum;
}