How do you rotate a two dimensional array?

后端 未结 30 3684
耶瑟儿~
耶瑟儿~ 2020-11-22 02:43

Inspired by Raymond Chen\'s post, say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I\'d

30条回答
  •  庸人自扰
    2020-11-22 03:41

    C code for matrix rotation 90 degree clockwise IN PLACE for any M*N matrix

    void rotateInPlace(int * arr[size][size], int row, int column){
        int i, j;
        int temp = row>column?row:column;
        int flipTill = row < column ? row : column;
        for(i=0;icolumn?i:0; i

提交回复
热议问题