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