Partition of an Integer + Number of partitions
A partition of an integer n is a way of writing n as a sum of positive integers. For example, for n=7, a partition is 1+1+5. I need a program that finds all the partitions of an integer 'n' using 'r' integers. For example, all the partitions of n=7 using r=3 integers are 1+1+5 , 1+2+4 , 1+3+3 , 2+2+3 . This is what I have so far: #include <iostream> #include <vector> using namespace std; void print (vector<int>& v, int level){ for(int i=0;i<=level;i++) cout << v[i] << " "; cout << endl; } void part(int n, vector<int>& v, int level){ int first; /* first is before last */ if(n<1) return ; v