程式語言 - LeetCode - C - 注意事項 - Array



二維記憶體配置方式

int** flipAndInvertImage(int **image, int imageSize, int *imageColSize, int *returnSize, int **returnColumnSizes) {
    int **p = malloc(sizeof(int*) * imageSize);

    *returnSize = imageSize;
    *returnColumnSizes = malloc(sizeof(int) * imageSize);
    for (c0 = 0; c0 < imageSize; c0++) {
        (*returnColumnSizes)[c0] = imageColSize[c0];
    }

    for (c0 = 0; c0 < imageSize; c0++) {
        p[c0] = malloc(sizeof(int) * imageColSize[c0]);
    }
    return p;
}