fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, end = 0;
  8. long double sum = 0, total = 0;
  9.  
  10. while (cin >> n)
  11. {
  12. if (n != 0)
  13. {
  14. sum += n;
  15. total += n;
  16. end = 0;
  17. }
  18.  
  19. else
  20. {
  21. cout << sum << endl;
  22. sum = 0;
  23. end += 1;
  24. }
  25.  
  26. if (end > 1)
  27. break;
  28. }
  29.  
  30. cout << total << endl;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 15240KB
stdin
11 8 2 -1 0
6 33 -9 10 0
12345678901 0
0
stdout
20
40
60