Advertisement
tanasaradu

Untitled

Nov 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,st[20],k;
  4. void BACK(int top)
  5. {
  6. if(top==(k+1))
  7. {
  8. for(int i=1;i<=k;i++)
  9. cout<<st[i]<<" ";
  10. cout<<"\n";
  11. }
  12. else for(int i=1+st[top-1];i<=n;i++)
  13. {
  14. st[top]=i;
  15. BACK(top+1);
  16. }
  17. }
  18. int main()
  19. {
  20. cin>>n>>k;
  21. BACK(1);
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement