- 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 Chart79 blogs
- Python77 blogs
- Java76 blogs
- Vue41 blogs
- MySQL27 blogs
- Linux22 blogs
- javascript20 blogs
- Database18 blogs
- more...

Daily Recommendation

views 9

views 7

views 6

views 5

views 4

©2020 ioDraw All rights reserved

Dormitory information management system JQ set up cookie（3 We'll do it in five minutes ）VUE Arrangement of basic knowledge points Embedded Software Engineer 2019 Summary of school recruitment First order low pass filter - Continuous to discrete python Basic exercises （ One ）Java——char Types and strings Six Star Education ：PHP Programmer's book , Let you quickly become a technical master springboot+vue+shiro Function authority 【Pytorch】BCELoss and BCEWithLogitsLoss Detailed explanation of loss function