void partitionOdd(int value) { int *result = malloc(sizeof(int) * value); partOdd(result, value, 0); result[0] = 1; free(result); }
void partitionOdd(int value) { int arr[MAXLENGTH] = {0}; //Make array values all 0 printf("partitionOdd %d\n", value); partOdd(value, arr, 0); //Intial starting index is 0 }
void partOdd(int *result, int remainder, int loc) { int i; int rem; for(i = 1; i <= remainder; i+=2) { result[loc] = i; rem = remainder - i; rem != 0 ? partOdd(result, rem, loc + 1) : printResult(result, loc + 1); } }
void partitionOdd(int value) { int ind = 0; printf("partitionOdd %d\n", value); void partOdd( int value, int * arr, int ind); int * arr = malloc(value * sizeof(int)); partOdd(value, arr, ind); free(arr); }
void partOdd(int value, int * arr, int ind) { int i; if(value == 0) { printArray(arr, ind); return; } //Start at 1, an odd number, and increment by 2 to stay on odd numbers for(i = 1; i <= value; i += 2) { arr[ind] = i; partOdd(value - i, arr, ind + 1); } }
void partOdd(int value, int* arr, int ind) { int n = 0; if (value == 0) { printpart(arr, ind); return; } for (n = 1; n <= value; n++) { if ((n % 2) != 0) { arr[ind] = n; partOdd(value - n, arr, ind + 1); } } }