标签:center col esc amp 个数 int targe http desc
最大子段和,最大能取所有
----------------------------------------------------------------
class Solution { public: int FindGreatestSumOfSubArray(vector<int> array) { if(array.size() == 0) return 0; if(array.size() == 1)return array[0]; int tempSum, maxSum; maxSum = -0xfffff; for (int i = 0; i < array.size(); i++) { // 子序列起始位置 for (int j = i; j < array.size(); j++) { // 子序列终止位置 tempSum = 0; for (int k = i; k <= j; k++) { // 子序列遍历求和 tempSum += array[k]; if (tempSum > maxSum) // 更新最大和值 maxSum = tempSum; } } } return maxSum; } };
标签:center col esc amp 个数 int targe http desc
原文地址:https://www.cnblogs.com/evidd/p/10630839.html