最大的子序列求和问题
时间复杂度:O(2N)
int maxSubArr() { int arr[] = {-2, 11, -4, 13, -5, -2}; int i, length, max, j; length = sizeof(arr) / sizeof(int); max = 0; int temp = 0; for(j = 0; j < length; j++) { temp += arr[j]; if (temp > max) { max = temp; } } temp = max; for(i = 1; i <= length; i++) { temp = temp - arr[i-1]; if (temp > max) { max = temp; } } return max; }