Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.txt");
- int main() {
- int x, sum, summax;
- fin >> x;
- sum = summax = x;
- while (fin >> x) {
- if (sum < 0) {
- sum += x;
- } else {
- sum = x;
- }
- if (sum < summax) {
- summax = sum;
- }
- }
- cout << summax << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement