最大连续和问题
时间:2010-08-30 来源:wsnhyjj
int MaxSubArraySum(int a[],int n)
{
int i;
int current=0;
int maxsum=0;
for(i=0;i<n;i++)
{
current = current+a[i]>0?current+a[i]:0;
maxsum = current>maxsum?current:maxsum;
}
return maxsum;
}
相关阅读 更多 +