#C2070. Diagonal Matrix Generator
Diagonal Matrix Generator
Diagonal Matrix Generator
You are given a number of test cases. For each test case, you are given an integer \(N\). Your task is to generate an \(N \times N\) matrix where the elements on both the main diagonal (i.e., \(a_{i,i}\)) and the secondary diagonal (i.e., \(a_{i,N-1-i}\)) are 1, and all other elements are 0.
The output for each test case should be the matrix printed row by row, with the elements in each row separated by a single space. Different test cases must be separated by a blank line.
Example:
Input: 2 3 4</p>Output: 1 0 1 0 1 0 1 0 1
1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1
inputFormat
The first line of input contains a single integer \(T\) indicating the number of test cases. Each of the following \(T\) lines contains one integer \(N\), representing the size of the square matrix.
Example:
3 3 4 5
outputFormat
For each test case, output the generated matrix. Each row must be printed on a new line with its elements separated by a space. The outputs for different test cases should be separated by a blank line.
Example:
1 0 1 0 1 0 1 0 1## sample</p>1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1
1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1
1
3
1 0 1
0 1 0
1 0 1
</p>