#K79322. Upper Diagonal Matrix Transformation
Upper Diagonal Matrix Transformation
Upper Diagonal Matrix Transformation
You are given a square matrix A of size N × N. Your task is to transform the matrix into its upper diagonal form. More formally, you need to construct a new matrix B such that
\( B_{ij} = \begin{cases} A_{ij}, & \text{if } i \leq j \\ 0, & \text{if } i > j \end{cases} \)
The input is provided via stdin and the output should be printed to stdout. Each row of the resulting matrix should be printed in a single line with values separated by a single space.
Example
Input: 3 1 2 3 4 5 6 7 8 9</p>Output: 1 2 3 0 5 6 0 0 9
inputFormat
The first line contains a single integer N representing the dimensions of the matrix. Each of the following N lines contains N space-separated integers, representing the matrix rows.
For example:
3 1 2 3 4 5 6 7 8 9
outputFormat
Output the transformed matrix in its upper diagonal form. Each row should be printed in one line with the elements separated by a single space.
For example:
1 2 3 0 5 6 0 0 9## sample
3
1 2 3
4 5 6
7 8 9
1 2 3
0 5 6
0 0 9
</p>