1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include "maklib.h"

using namespace std;

int main()
{
    int p = 0, k = 0, suma = 0, maxi = 0;

    for (int i = 1; i <= Size(); i++)
    {
       suma += ElementAt(i);

       if (suma > maxi) { maxi = suma; k=i; }
       if (suma < 0) { suma = 0; p = i+1;}
    }

    cout << maxi;

    return 0;
}