标签:color returns als void call ++ 合并 ssi size
int cmp(const void*a, const void*b){ return (*(int**)a)[0] > (*(int**)b)[0]; } int** merge(int** intervals, int intervalsSize, int* intervalsColSize, int* returnSize, int** returnColumnSizes){ int** arr = (int**)calloc(intervalsSize, sizeof(int*)); *returnSize = 0; *returnColumnSizes = (int*)calloc(intervalsSize, sizeof(int)); qsort(intervals, intervalsSize, sizeof(int*), cmp); for (int i = 0; i < intervalsSize; i++){ if (i == intervalsSize - 1 || intervals[i][1] < intervals[i + 1][0]){ arr[(*returnSize)] = (int*)calloc(2, sizeof(int*)); arr[(*returnSize)][0] = intervals[i][0]; arr[(*returnSize)][1] = intervals[i][1]; (*returnColumnSizes)[(*returnSize)++] = 2; } else if (intervals[i][1] >= intervals[i + 1][0]){ intervals[i + 1][0] = intervals[i][0]; intervals[i + 1][1] = (intervals[i][1]>intervals[i + 1][1]) ? intervals[i][1] : intervals[i + 1][1]; } } return arr; }
标签:color returns als void call ++ 合并 ssi size
原文地址:https://www.cnblogs.com/ganxiang/p/14118336.html