int* constructArr(int* a, int aSize, int* returnSize){ int *arr = NULL; int i, temp; if (a == NULL || aSize <= 1) { *returnSize = 0; return a; } *returnSize = aSize; arr = (int *)malloc(sizeof(int) * aSize); arr[0] = 1; for (i = 1; i < aSize; i++) { arr[i] = arr[i - 1] * a[i - 1]; } temp = 1; for (i = aSize - 2; i >= 0; i--) { temp *= a[i + 1]; arr[i] *= temp; } return arr; }