int maxSubSum(int *a,int len)
{
int maxSum = a[0];
int thisSum = 0;
for (int i = 0;i < len; i++)
{
thisSum += a[i];
if (thisSum > maxSum)
{
maxSum = thisSum;
}
else if (thisSum < 0)
{
thisSum =0;
}
}
return maxSum;
}
int main()
{
int arr[] = {-2,-3,-4,-10,-9,-4,-2,-4,-6};
cout<<"最大子序列和是:"<<maxSubSum(arr,9)<<endl;
}