Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <sstream>
- using namespace std;
- void findPartitions(int num, int min = 1, string partitions = "") {
- if (!num) {
- cout << partitions << endl;
- return;
- }
- for (int i = num; i >= min; --i)
- findPartitions(num - i, i, partitions + to_string(i) + " ");
- }
- int main() {
- int N;
- cin >> N;
- findPartitions(N);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement