Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int st[100], i, n;
- void backtrack(int k)
- {
- if(k == n+1)
- {
- for(i = 1; i <= n; i++)
- cout << st[i] << " ";
- cout << "\n";
- }
- else
- {
- st[k] = 0;
- while(st[k] < n)
- {
- st[k]++;
- backtrack(k+1);
- }
- }
- }
- int main()
- {
- cin >> n;
- backtrack(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement