题目描述
输入一个3*3的数字矩阵,输出顺时针旋转90度后的数字矩阵。
输入
输入一个3*3的数字矩阵。
输出
输出顺时针旋转90度后的数字矩阵。
样例输入 Copy
1 2 3
4 5 6
7 8 9
样例输出 Copy
7 4 1
8 5 2
9 6 3
#include <stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
int m,n,a[12][12],o,p;
m=3;n=3;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(j==1) o=3;
else if(j==3) o=1;
else o=2;
printf("%d",a[o][i]);
if(j!=m)printf(" ");
}
printf("\n");
}
}