Advertisement
podsolnyxxx

Дискретка 2 сем. 1 лаб. M

Apr 12th, 2024 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <sstream>
  5.  
  6. using namespace std;
  7.  
  8. void findPartitions(int num, int min = 1, string partitions = "") {
  9. if (!num) {
  10. cout << partitions << endl;
  11. return;
  12. }
  13.  
  14. for (int i = num; i >= min; --i)
  15. findPartitions(num - i, i, partitions + to_string(i) + " ");
  16. }
  17.  
  18. int main() {
  19. int N;
  20.  
  21. cin >> N;
  22.  
  23. findPartitions(N);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement