void rotate(int** matrix, int matrixSize, int* matrixColSize){ for (int i = 0; i < (matrixSize + 1) / 2; i++){ for (int j = 0; j < matrixSize / 2; j++){ int tmp = matrix[i][j]; matrix[i][j] = matrix[matrixSize - 1 - j][i]; matrix[matrixSize - 1 - j][i] = matrix[*matrixColSize - 1 - i][matrixSize - 1 - j]; matrix[*matrixColSize - 1 - i][matrixSize - 1 - j] = matrix[j][*matrixColSize - 1 - i]; matrix[j][*matrixColSize - 1 - i] = tmp; } } }
void rotate(int** matrix, int matrixSize, int* matrixColSize){ int i, j, tmp; int hash[20][20] = { 0 }; for (i = 0; i < matrixSize; i++){ for (j = 0; j < *matrixColSize; j++) { if (hash[i][j] == 0){ tmp = matrix[i][j]; matrix[i][j] = matrix[matrixSize - 1 - j][i]; matrix[matrixSize - 1 - j][i] = matrix[*matrixColSize - 1 - i][matrixSize - 1 - j]; hash[matrixSize - 1 - j][i]++; matrix[*matrixColSize - 1 - i][matrixSize - 1 - j] = matrix[j][*matrixColSize - 1 - i]; hash[*matrixColSize - 1 - i][matrixSize - 1 - j]++; matrix[j][*matrixColSize - 1 - i] = tmp; hash[j][*matrixColSize - 1 - i]++; } } } }