1
public
static
int
LargeSum(
int
[] input)
2 {
3 int sum = 0, maxSum = -((int)Math.Pow(2, 32) - 1);
4
5 for (int i = 0; i < input.Length; i++)
6 {
7 sum += input[i];
8 if (maxSum < sum)
9 {
10 maxSum = sum;
11 }
12 if (sum < 0)
13 {
14 sum = 0;
15 }
16 }
17
18 return maxSum;
19 }
2 {
3 int sum = 0, maxSum = -((int)Math.Pow(2, 32) - 1);
4
5 for (int i = 0; i < input.Length; i++)
6 {
7 sum += input[i];
8 if (maxSum < sum)
9 {
10 maxSum = sum;
11 }
12 if (sum < 0)
13 {
14 sum = 0;
15 }
16 }
17
18 return maxSum;
19 }