输出一个N*N的旋转矩阵
1 #include
2 int main()
3 {
4 int m = 0;
5 int now_n = 1;
6 int left,right;
7 int up,down;
8 int i = 1,j = 1;
9 int a[10][10];
10 printf("input your m:");
11 scanf("%d",&m);
12
13 left = 1;
14 right = m;
15 up = 1;
16 down = m;
17 while(left = ...全部
1 #include
2 int main()
3 {
4 int m = 0;
5 int now_n = 1;
6 int left,right;
7 int up,down;
8 int i = 1,j = 1;
9 int a[10][10];
10 printf("input your m:");
11 scanf("%d",&m);
12
13 left = 1;
14 right = m;
15 up = 1;
16 down = m;
17 while(left = left ; i--)
29 a[j][i] = now_n++;
30 down -= 1;
31 i += 1;
32 for(j = down ; j >= up ; j--)
33 a[j][i] = now_n++;
34 left += 1;
35 j += 1;
36 }
37 for(i = 1 ; i <= m ; i++)
38 {
39 for(j = 1 ; j <= m ; j++)
40 {
41 printf("%3d",a[i][j]);
42 }
43 printf("\n");
44 }
45 return 0;
46 }
。
收起