xxeell

magick_with_goto

Oct 8th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int portal_val = 0;
  8.     int params[10];
  9.     int results[10];
  10.     goto prg_start;
  11.  
  12. portals:
  13.  
  14.     switch(portal_val)
  15.     {
  16.         case 0 : goto prg_start;
  17.         case 1 : goto after_f;
  18.         //
  19.         default : goto prg_start;
  20.     }
  21.  
  22. start_f:
  23.  
  24.     results[0] = params[0] * params[0];
  25.     goto portals;
  26.  
  27. prg_start:
  28.  
  29.     int x;
  30.     cout << "enter X:" << endl;
  31.     cin >> x;
  32.  
  33.     // start sqr func
  34.     params[0] = x;
  35.     portal_val = 1;
  36.     goto start_f;
  37. after_f:
  38.     int res = results[0];
  39.     cout << "Answer: " << res << endl;
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment