Question d’entretien chez Knoldus Software

Rotate the array elements clockwise.

Réponses aux questions d'entretien

Utilisateur anonyme

24 mai 2017

I wrote the code on paper.

2

Utilisateur anonyme

22 sept. 2017

// C++ program to rotate a matrix #include #include #define R 3 #define C 3 // A function to rotate a matrix mat[][] of size R x C. // Initially, m = R and n = C void rotatematrix(int m, int n, int mat[R][C]) { int row = 0, col = 0; int prev, curr; clrscr(); /* row - Staring row index m - ending row index col - starting column index n - ending column index i - iterator */ while (row = col; i--) { curr = mat[m-1][i]; mat[m-1][i] = prev; prev = curr; } } m--; /* Move elements of first column from the remaining rows */ if (col = row; i--) { curr = mat[i][col]; mat[i][col] = prev; prev = curr; } } col++; } // Print rotated matrix for (int i=0; i

1