fork(2) download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3.  
  4. int intNum = 0;
  5.  
  6. void ShowScr(void (*p)()=0 )
  7. {
  8. cout << intNum << "\n";
  9. cin >> intNum;
  10. p();
  11. }
  12.  
  13. int main() {
  14.  
  15.  
  16. cin >> intNum;
  17. while (intNum != 42) {
  18.  
  19. ShowScr(
  20.  
  21. [](){ cout << "-" ; }
  22.  
  23. );
  24.  
  25. }
  26.  
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3460KB
stdin
1
2
10
42
11
stdout
1
-2
-10
-