Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- ///****************
- #define NMAX 22
- int st[NMAX], n, k;
- void backTr() {
- for (int i = 1; i <= k; i++)
- cout << st[i] << ' ';
- if (k)
- cout << endl;
- for (int i = st[k] + 1; i <= n; i++) {
- st[++k] = i;
- backTr();
- k--;
- }
- }
- int main() {
- cin >> n;
- backTr();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement