fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. int main()
  4. {
  5. using namespace std;
  6. int ctr = 0, i = 0, tmp = 0;
  7. while (ctr < 3)
  8. {
  9. tmp = i;
  10. cin >> i;
  11. if(i == 42 && tmp != 42) ctr++;
  12. else if (i == 42 && tmp == 42) ctr--;
  13. //if (ctr < 0) ctr = 0;
  14. cout << setfill('0') << setw(2) << i << endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 5416KB
stdin
42
42
12
13
42
11
42
43
42
42
99
01
stdout
42
42
12
13
42
11
42
43
42