Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("partmult.in");
  5. ofstream fout("partmult.out");
  6.  
  7. int n, st[1000];
  8. void afisare(int mx)
  9. {
  10. for(int i = 1; i <= mx; i++)
  11. {
  12. for(int j = 1; j <= n; j++)
  13. {
  14. if(st[j] == i)
  15. {
  16. fout << j << ' ';
  17. }
  18. }
  19. if(i != mx) fout << ';' << ' ';
  20. }
  21. fout << '\n';
  22. }
  23. void bkt(int k, int mx)
  24. {
  25. if(k == n + 1)
  26. {
  27. afisare(mx);
  28. }
  29. else
  30. {
  31. for(int i = 1; i <= mx; i++)
  32. {
  33. st[k] = i;
  34. bkt(k + 1, mx);
  35. }
  36. st[k] = mx + 1;
  37. bkt(k + 1, mx + 1);
  38. }
  39. }
  40. int main()
  41. {
  42. fin >> n;
  43. bkt(1, 0);
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement