示例#1
0
void partitionDecreasing(int value)
{
  int arr[MAXLENGTH] = {0}; //Make array values all 0

  printf("partitionDecreasing %d\n", value);

  partDec(value, arr, 0, value); //Initial index is 0 and initial starting point is the value being input
}
示例#2
0
void partitionDecreasing(int value)
{
  int ind = 0;
  
  printf("partitionDecreasing %d\n", value);
  void partDec( int value, int * arr, int ind);
  
  int * arr = malloc(value * sizeof(int));
  partDec(value, arr, ind);
  free(arr);
  
}
示例#3
0
void partDec(int value, int * arr, int ind)
{
  int n = 0;
  
  if (value == 0)
  {
    printpart(arr, ind);
    return;
  }
  
  for (n = 1; n <= value; n++)
  {
    arr[ind] = n;
    if (ind == 0)
    {
      partDec(value - n, arr, ind + 1);
    }
    else if ( arr[ind] < arr[ind - 1])
    {
      arr[ind] = n;
      partDec(value - n, arr, ind + 1);
    }
  }
}
示例#4
0
void partDec(int value, int * arr, int ind, int start)
{
  int i;

  if(value == 0)
  {
    printArray(arr, ind);
    return;
  }

  //Decrement array since we are starting at the highest possible number and going down
  for(i = start; i > 0; i--)
  {
    arr[ind] = i;

    partDec(value - i, arr, ind + 1, i - 1);
  }
}