Previous Next
0 / 21
Module DEMO-32-109DEMO-C-32

Transpose

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program to compute the transpose of an N x M matrix. The transpose is obtained by swapping rows and columns.

Constraints

1 <= N, M <= 10. Integers within standard range.

Input Format

Input: Dimensions N M followed by the matrix elements.

Output Format

Output: The formatted result as specified.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
4 5
47 -6 14 34 9
1 23 6 6 46
2 7 8 2 14
-5 32 3 26 -2
47 1 2 -5
-6 23 7 32
14 6 8 3
34 6 2 26
9 46 14 -2
Transposed 4x5 to 5x4.
Sample #2
Public sample
2 2
50 25
14 38
50 14
25 38
Transposed 2x2 to 2x2.
Sample #3
Public sample
5 4
44 23 11 46
-2 -8 20 27
25 11 12 49
4 2 3 18
35 6 15 39
44 -2 25 4 35
23 -8 11 2 6
11 20 12 3 15
46 27 49 18 39
Transposed 5x4 to 4x5.
Sample #4
Public sample
2 3
11 21 23
1 -5 44
11 1
21 -5
23 44
Transposed 2x3 to 3x2.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings