Advertisement
STANAANDREY

bacT7 SIII 3

May 28th, 2021
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("bac.txt");
  5.  
  6. int main() {
  7.     int x, sum, summax;
  8.     fin >> x;
  9.     sum = summax = x;
  10.     while (fin >> x) {
  11.         if (sum < 0) {
  12.             sum += x;
  13.         } else {
  14.             sum = x;
  15.         }
  16.         if (sum < summax) {
  17.             summax = sum;
  18.         }
  19.     }
  20.     cout << summax << endl;
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement