fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int a,b,p=1,i=0;
  5. bool p1=1;
  6. int main()
  7. {
  8. while(p1==1)
  9. {
  10. cin>>a;
  11.  
  12. if(i>=3&&b!=42&&a==42)
  13. {
  14. p1=0;
  15. cout<<a;
  16. }
  17. if(p1!=0)
  18. {
  19. cout<<a<<endl;
  20. }
  21.  
  22. if(a==42&&b!=42){i++;}
  23.  
  24. b=a;
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 15232KB
stdin
42
42
12
13
42
11
42
43
42
42
99
01
stdout
42
42
12
13
42
11
42
43
42