tanasaradu

Untitled

Oct 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("combinari.in");
  4. ofstream fout("combinari.out");
  5. const short NMAX=20;
  6. int top,st[NMAX],n,k;
  7. void BACK(int top)
  8. {
  9. if(top==(k+1))
  10. {
  11. for(int i=1;i<=k;i++)
  12. fout<<st[i]<<" ";
  13. fout<<"\n";
  14. }
  15. else for(int i=1+st[top-1];i<=n;i++)
  16. {
  17. st[top]=i;
  18. BACK(top+1);
  19. }
  20. }
  21. int main()
  22. {
  23. fin>>n>>k;
  24. BACK(1);
  25. fin.close();
  26. fout.close();
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment