Advertisement
STANAANDREY

submultimi

Sep 11th, 2020
1,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. ///****************
  4. #define NMAX 22
  5. int st[NMAX], n, k;
  6.  
  7. void backTr() {
  8.     for (int i = 1; i <= k; i++)
  9.         cout << st[i] << ' ';
  10.     if (k)
  11.         cout << endl;
  12.     for (int i = st[k] + 1; i <= n; i++) {
  13.         st[++k] = i;
  14.         backTr();
  15.         k--;
  16.     }
  17. }
  18.  
  19. int main() {
  20.     cin >> n;
  21.     backTr();
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement