标签:
bool g_InvalidInput = false;
int FindGreatestSumOfSubArray(int *pData, int nLength)
{
if ((pData == NULL) || (nLength <= 0))
{
g_InvalidInput = true;
return 0;
}
g_InvalidInput = false;
int nCurSum = 0;
int nGreatestSum = 0X80000000;
for (int i = 0; i < nLength; ++i)
{
if (nCurSum <= 0)
nCurSum = pData[i];
else
nCurSum += pData[i];
if (nCurSum > nGreatestSum)
nGreatestSum = nCurSum;
}
return nGreatestSum;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/wangfengfan1/article/details/46820557