Advertisement
tanasaradu

Untitled

Nov 23rd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,st[20],k,a[1005];
  4. void BACK(int top)
  5. {
  6. if(top==(k+1))
  7. {
  8. for(int i=1;i<=k;i++)
  9. cout<<a[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. for(int i=1;i<=n;i++)
  22. cin>>a[i];
  23. sort(a+1,a+n+1);
  24. BACK(1);
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement