fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int liczba;
  5. long long int suma = 0, kot = 0;
  6.  
  7. int main()
  8. {
  9. while (cin >> liczba)
  10. {
  11. kot += liczba;
  12. if (liczba == 0) cout << kot<< endl;
  13.  
  14. if (kot == 0 && liczba == 0)
  15. {
  16. cout << suma << endl;
  17. suma = 0;
  18. }
  19. else if (liczba == 0) kot = 0;
  20. else suma += liczba;
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 15232KB
stdin
11 8 2 -1 0
6 33 -9 10 0
0
stdout
20
40
0
60