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 s = 0, smin = 0, negat = 0;
- int x, xmin = 1000;
- while(fin >> x)
- {
- s = s + x;
- if(s < smin)
- smin = s;
- if(s > 0)
- s = 0;
- if(x < 0)
- negat++;
- if(x < xmin)
- xmin = x;
- }
- if(negat == 0)
- cout << xmin;
- else
- cout << smin;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement