fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n;
  9. string s;
  10.  
  11. while(cin >> n)
  12. cout << n << ' ';
  13.  
  14. cin.clear(); // сбрасываем ошибку в cin
  15. cin.sync(); // убираем из cin лишнее
  16. cin >> n;
  17. cout << '\n' << n << '\n';
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3460KB
stdin
1 2 3 4 5 $
4
stdout
1 2 3 4 5 
0