Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int mat1[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- int mat2[3][2];
- printf("Original matrix:\n");
- for(int i = 0; i<3; i++){
- for(int j=0; j<3; j++){
- printf("%d ", mat1[i][j]);
- }
- printf("\n");
- }
- printf("Rotated matrix:\n");
- mat2[0][0] = mat1[2][0];
- mat2[0][1] = mat1[1][0];
- mat2[0][2] = mat1[0][0];
- mat2[1][0] = mat1[2][1];
- mat2[1][1] = mat1[1][1];
- mat2[1][2] = mat1[0][1];
- mat2[2][0] = mat1[2][2];
- mat2[2][1] = mat1[1][2];
- mat2[2][2] = mat1[0][2];
- for(int a = 0; a<3; a++){
- for(int b=0; b<3; b++){
- printf("%d ", mat2[a][b]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement