标签:
1 bool g_InvalidInput=false; 2 3 4 5 int FindGreatestSumOfSubArray(int *pData,int nLength) 6 7 { 8 9 if((pData==NULL)||(nLength<=0)) 10 11 { 12 13 g_InvalidInput=true; 14 15 return 0; 16 17 } 18 19 g_InvalidInput=false; 20 21 int nCurSum=0; 22 23 int nGreatestSum=0x80000000; 24 25 for(int i=0;i<nLength;++i) 26 27 { 28 29 if(nCurSum<=0) 30 31 nCurSum=pData[i]; 32 33 else 34 35 nCurSum +=pData[i]; 36 37 if(nCurSum>nGreatestSum) 38 39 nGreatestSum=nCurSum; 40 41 } 42 43 return nGreatestSum; 44 45 }
标签:
原文地址:http://www.cnblogs.com/wxdjss/p/5483581.html