#C3590. Identity Matrix Generator
Identity Matrix Generator
Identity Matrix Generator
In this problem, you are given two integers (n) and (m) which represent the number of rows and columns respectively. Your task is to generate an identity matrix of dimensions (n \times m). An identity matrix is a matrix in which all the elements of the principal diagonal are 1 and all other elements are 0. More formally, the element at the (i)-th row and (j)-th column, (I_{ij}), is defined as
[ I_{ij} = \begin{cases} 1, & \text{if } i = j \text{ and } i \leq \min(n, m) \ 0, & \text{otherwise} \end{cases} ]
Print the matrix such that each row is on a new line and the elements in each row are separated by a single space. Note that the numbers should be represented as floating point numbers (e.g., 1.0 for one).
inputFormat
The input consists of a single line containing two space-separated integers (n) and (m) ( (1 \leq n, m \leq 100)), representing the number of rows and columns of the matrix.
outputFormat
Output the (n \times m) identity matrix. Each row should be printed on a new line with the elements separated by a single space. Each number must be printed as a floating point number (e.g., 1.0 or 0.0).## sample
3 3
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
</p>