【leetcode】 转置矩阵

 

int** transpose(int** A, int ASize, int* AColSize, int* returnSize, int** returnColumnSizes){
    
    int** arr = (int**)calloc(*AColSize,sizeof(int*));
    for (int i=0; i<*AColSize; i++)
    {
        int* row = (int*)calloc(ASize,sizeof(int));
        for (int j=0; j<ASize; j++)
        {
            row[j] = A[j][i];
        }
        (*returnColumnSizes)[i] = ASize;
        arr[i] = row;
    }
    *returnSize = *AColSize;
    return arr;
}

 

posted @ 2020-08-30 14:50  温暖了寂寞  阅读(135)  评论(0编辑  收藏  举报