#include <iostream>
using namespace std;
int NumberOfPartitions(int array[], int length, int target);
int main()
{
int sampleSet[] = {1, 3, 4, 5};
int sz = sizeof(sampleSet) / sizeof(int);
cout << NumberOfPartitions(sampleSet, sz, 5) << endl
<< NumberOfPartitions(sampleSet, sz, 11) << endl;
return 0;
}
int NumberOfPartitions(int array[], int length, int target)
{
// simple case
if (length == 0) {
if (target == 0) return 1;
else return 0;
}
return NumberOfPartitions(array, length-1, target-array[length-1]) +
NumberOfPartitions(array, length-1, target);
}