- 2020-08-07 07:01
*views 4*- my ACM

<> Dance of matrix

Problem Description

Matrices are wonderful things , It can be used to solve equations , And solve some problems of graph theory , It is widely used . Even without learning linear algebra , You must have been exposed to the matrix , In programming can be understood as a two-dimensional table .

The matrix has a lot of operations, like dancing , Such as the replacement of row and column , Transposition of matrix, etc . Today we only look at the rotation of the matrix , Want to get the current matrix clockwise rotation 90 Matrix after degree .

Input

The first line of input data is a positive integer T, Representatives are T Sample group test . next T Group data , The first row of each set of data is two integers M,N (0 < M , N <

100), Represent the number of rows and columns of the matrix respectively . Then there is the matrix itself , common M That's ok , Each line N Data is separated by a space .

Output

For each input matrix , First line output Case #k:（k Is the serial number of the data set , See the example for the specific format ）, Then output its rotated matrix .

Sample Input

2

4 4

1 2 3 4

5 6 7 8

6 6 6 6

8 8 8 8

2 3

1 2 3

4 5 6

Sample Output

Case #1:

8 6 5 1

8 6 6 2

8 6 7 3

8 6 8 4

Case #2:

4 1

5 2

6 3

Sample code ：

#include<stdio.h> int main(void) { int N, i, j; int m, n, a[100][100];

scanf("%d", &N); for (int I = 1; I <= N; I++) { scanf("%d %d", &m, &n); for (i

= 0; i < m; i++) for (j = 0; j < n; j++) scanf("%d", &a[i][j]); printf("Case

#%d:\n", I); for(i=0;i<n;i++) for (j = 0; j < m; j++) { if(j==m-1)

printf("%d\n", a[m - 1 - j][i]); else printf("%d ", a[m - 1 - j][i]); } }

return 0; }

Technology

- Flow Chart77 blogs
- Java38 blogs
- Python32 blogs
- MySQL16 blogs
- Linux16 blogs
- Android15 blogs
- Administration13 blogs
- Database12 blogs
- more...

Daily Recommendation

©2020 ioDraw All rights reserved

error: (-215:Assertion failed) Solution python Simple record of network programming mac solve Enter passphrase for key Enter the password each time Huawei Hongmeng system learning notes 9- Ecological construction of developers Apple iPhone 12 Price leakage ： The official highest price is close to 1 Ten thousand yuan Docker Import of containers and mirrors , export Cross analysis of data analysis Notes on core principles of reverse engineering （ One ）——Hello World-1Python Student information management system ( Lite ) Ant old employees leave early and miss millions of wealth , Some people say they don't regret it