-->
当前位置:首页 > 题库

PROGRAMMING:Matrix transpose

Luz5年前 (2021-05-10)题库403
Input a positive integer n (1 < n ≤ 6), generate a square matrix of n * n according to the following formula, and then transpose the square matrix (row and column exchange) and output it.
a[i][j] = i * n + j + 1(0≤i≤n-1,0≤j≤n-1)
###Input format:
Enter a positive integer n (1 < n ≤ 6), note that there is no input prompt
###Output format:
Output as% 4D, note that there is a line break after the last number
###Input example:
```in
three
```
###Output example:
```out
The corresponding output is given here. For example:
1 4 7
2 5 8
3 6 9
```






answer:If there is no answer, please comment