daily pastebin goal
15%
SHARE
TWEET

Printing numbers (Recursion)

TamarMepe Mar 23rd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include "console.h"
  3. #include "vector.h"
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7. const int SENTINEL = -1;
  8. void rec();
  9. int main() {
  10.     rec();
  11.     return 0;
  12. }
  13.  
  14. void rec(){
  15.     int x;
  16.     cin >> x;
  17.     if (x == SENTINEL) return;
  18.     rec();
  19.     cout << x << endl;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top