/**************************
Meno a Priezvisko : Rudolf Tomek
Datum : 29.4
Uloha : CW12/24 SKUPINA S2 PSEUDOCODE_2: MaxSoučet2
******************************/
using System;
public class Program {
public static int MaxSoucet2(int[] X) {
int n = X.Length;
int m = 0;
for (int i = 0; i < n; i++) {
int s = 0;
for (int j = i; j < n; j++) {
s += X[j];
m = Math.Max(m, s);
}
return m;
public static void Main (string[] args) {
int[] X = { -2, 1, -3, 4, -1, 2, 1, -5, 4 };
Console.WriteLine(MaxSoucet2(X));