fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. long long sum = 0, num;
  7. int cnt = 0;
  8.  
  9. while(cin >> num)
  10. {
  11. sum += num;
  12. ++cnt;
  13. }
  14.  
  15. cout << "Got " << cnt << " numbers, sum: " << sum << endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 4352KB
stdin
1 2
3 4
stdout
Got 4 numbers, sum: 10