Пример #1
0
void partitionOdd(int value)
{
  int *partition = malloc(sizeof(int) * value);
  partitionOddHelper(value, partition, 0);
  free(partition);

}
Пример #2
0
void partitionOddHelper(int budget, int *partition, int pos)
{
  //BASE CASE!!!
  if (budget == 0){
    printpartition(partition, pos);
    return;
  }  

  //INDUCTIVE CASE!!!!!
  int spending;
  for(spending = 1; spending <= budget ; spending += 2){
    partition[pos] = spending;
    partitionOddHelper(budget - spending, partition, pos + 1);
  }
}
Пример #3
0
void partitionOddHelper(int N, int *partition, int pos)
{
	//BASE CASE
	if(N == 0)
	{
	printPartition(partition, pos);
	return;
	}
	//INDUCTIVE CASE
	int i; 
	for(i = 1; i <= N; i+= 2)
	{
	partition[pos] = i;
	partitionOddHelper(N - i, partition, pos + 1);
	}
}