void rotate_cw(int M, int array[4][4], int count) {
int rotatedArray[4][4];
while (count--) {
for (int row = 0; row < M; ++row) {
for (int col = 0; col < M; ++col) {
rotatedArray[row][col] = array[M - 1 - col][row];
}
}
for (int row = 0; row < M; ++row) {
for (int col = 0; col < M; ++col) {
array[row][col] = rotatedArray[row][col];
}
}
}
}
void rotate_ccw(int M, int array[4][4], int count) {
int rotatedArray[4][4];
while (count--) {
for (int row = 0; row < M; ++row) {
for (int col = 0; col < M; ++col) {
rotatedArray[row][col] = array[col][M - 1 - row];
}
}
for (int row = 0; row < M; ++row) {
for (int col = 0; col < M; ++col) {
array[row][col] = rotatedArray[row][col];
}
}
}
}