代码实现:
方法一:暴力法
方法二:动态规划
int maxProduct(int *nums, int numsSize) {long imax = nums[0], imin = nums[0], res = nums[0];for (int i = 1; i < numsSize; i++) {if (nums[i] < 0) {int temp = imax;imax = imin;imin = temp;}imax = fmax((int)(imax * nums[i]), nums[i]);imin = fmin((int)(imin * nums[i]), nums[i]);res = fmax(imax, res);}return res; }