Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class SequenceMaxSum
- {
- static void Main()
- {
- int[] array = { 2, 3, -6, -1, 2, -1, 6, 4, -8, 8 };
- int localSum = 0;
- int biggestSum = 0;
- for (int index = 0; index < array.Length; index++)
- {
- localSum += array[index];
- if (localSum > biggestSum)
- {
- biggestSum = localSum;
- }
- if (localSum == 0)
- {
- localSum += array[index];
- }
- }
- Console.WriteLine(biggestSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement