[ create a new paste ] login | about

Link: http://codepad.org/AQTFVd0z    [ raw code | output | fork ]

C, pasted on Nov 20:
#include <stdio.h>                                                                                                                                           

printM(char m[3][3]){
        printf("%d ", m[0][0]);
        printf("%d ", m[0][1]);
        printf("%d\n", m[0][2]);

        printf("%d ", m[1][0]);
        printf("%d ", m[1][1]);
        printf("%d\n", m[1][2]);

        printf("%d ", m[2][0]);
        printf("%d ", m[2][1]);
        printf("%d\n", m[2][2]);
}

int main(){
        int i,j;

        char m[3][3] = {{1,4,7},{2,5,8},{3,6,9}};
        char r[3][3];

        printM(m);

        for (i = 2 ; i >= 0 ; --i)
                for(j = 2 ; j >= 0 ; --j)
                        r[i][j] = m[2-j][i];

        printf("\n");
        printM(r);

        return 0;
}


Output:
1
2
3
4
5
6
7
1 4 7
2 5 8
3 6 9

3 2 1
6 5 4
9 8 7


Create a new paste based on this one


Comments: