Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 10th, 2020 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int n = 3;
  5. int used[n + 1];
  6. int a[n];
  7.  
  8.  
  9. void print() {
  10.     for (int i = 0; i < n; ++i) {
  11.         cout << a[i] << ' ';
  12.     }
  13.     cout << '\n';
  14. }
  15.  
  16. void rec(int idx) {
  17.     for (int i = 1; i <= n; ++i) {
  18.         if (!used[i]) {
  19.             used[i] = true;
  20.             a[idx] = i;
  21.             if (idx == n - 1) {
  22.                 print();
  23.             }
  24.             else {
  25.                 rec(idx + 1);
  26.             }
  27.             used[i] = false;
  28.         }
  29.     }
  30. }
  31. int main() {
  32.     for (int i = 1; i <= n; ++i) {
  33.         used[i] = false;
  34.     }
  35.     rec(0);
  36.     return 0;
  37. }
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