- 2020-08-07 07:01
*views 5*- 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

- Python122 blogs
- Java114 blogs
- Flow Chart79 blogs
- Vue66 blogs
- MySQL35 blogs
- javascript33 blogs
- programing language33 blogs
- Linux32 blogs
- more...

Daily Recommendation

views 7

©2020 ioDraw All rights reserved

【webpack】DLL plugin Principle analysis Combined with source code Transformer The most comprehensive , The deepest analysis filemanager-webpack-plugin Turn resources into zip Package and archive JavaScript study （ Function declaration and parameters ） mean value - Implementation and application of variance model _python_ Data analysis _9JAVA Snake games （ Source code + notes ）SpringBoot integrate Redisson Implement delay queue python code , Easy to complete Snake games Thread.setDaemon Set up the Daemons Unity Code dynamic creation of preform in editor expansion function