#include <iostream> #include "maklib.h" using namespace std; int main() { long long int amount, number, currentSeries = 0, maxSeries = 0; amount = Size(); for(long long int i=1; i<=amount; i++){ currentSeries += ElementAt(i); if(currentSeries > 0){ if(currentSeries > maxSeries) maxSeries = currentSeries; } else currentSeries = 0; } cout<<maxSeries<<endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <iostream> #include "maklib.h" using namespace std; int main() { long long int amount, number, currentSeries = 0, maxSeries = 0; amount = Size(); for(long long int i=1; i<=amount; i++){ currentSeries += ElementAt(i); if(currentSeries > 0){ if(currentSeries > maxSeries) maxSeries = currentSeries; } else currentSeries = 0; } cout<<maxSeries<<endl; } |