标签:网格 col idc sizeof ids turn shift for call
int** shiftGrid(int** grid, int gridSize, int* gridColSize, int k, int* returnSize, int** returnColumnSizes){
int** arr = (int**)calloc(gridSize,sizeof(int*));
int i,j,row,col;
for (i=0; i<gridSize; i++)
{
int* rowAddr = (int*)calloc(gridColSize[i],sizeof(int));
arr[i] = rowAddr;
}
for (i=0; i<gridSize; i++)
{
for (j=0; j<gridColSize[i]; j++)
{
row = (gridColSize[i]*i+j+k)/gridColSize[i]%gridSize;
col = (gridColSize[i]*i+j+k)%gridColSize[i];
arr[row][col] = grid[i][j];
}
(*returnColumnSizes)[i] = gridColSize[i];
}
*returnSize = gridSize;
return arr;
}
标签:网格 col idc sizeof ids turn shift for call
原文地址:https://www.cnblogs.com/ganxiang/p/13621533.html