fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int x;
  7. int ile=0;
  8. do{
  9. cin>>x;
  10. if(x==2)ile++;
  11. cout<<x<<" ";
  12.  
  13. }
  14. while(ile<3);
  15.  
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5284KB
stdin
1 2 3 4 5 2 1 3 4 2 1 2 3
stdout
1 2 3 4 5 2 1 3 4 2