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

PROGRAMMING:Construction of identity matrix

Luz5年前 (2021-05-10)题库429
The identity matrix is a matrix whose main diagonal is 1 and others are 0.
Enter the integer n (1 ≤ n ≤ 10) to construct an n × The identity matrix of n. Output the constructed matrix.
Hint: all 0 matrix can be obtained by initialization, such as: int a [3] [3] = {0}; We can get a 3 with all zeros × 3 matrix.
###Input format:
Enter n.
###Output format:
n × Matrix of n
Each number is followed by a space of N lines.
###Input example:
```in
five
```
###Output example:
```out
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
```







answer:If there is no answer, please comment