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