## Algorithm

Problem Name: beecrowd | 1435

# Square Matrix I

Adapted by Josué P. de Castro Brazil

Timelimit: 2

Write a program that read an integer number N (0 ≤ N ≤ 100) that correspond to the order of a Bidimentional array of integers, and build the Array according to the above example.

## Input

The input consists of several integers numbers, one per line, corresponding to orders from arrays to be built. The end of input is indicated by zero (0).

## Output

For each integer number of input, print the corresponding array according to the example. (the values ​​of the arrays must be formatted in a field of size 3 right justified and separated by a space. None space must be printed after the last character of each row of the array. A blank line must be printed after each array.

 Sample Input Sample Output 1 2 3 4 5 0 1     1   1   1   1     1   1   1   1   2   1   1   1   1       1   1   1   1   1   2   2   1   1   2   2   1   1   1   1   1     1   1   1   1   1   1   2   2   2   1   1   2   3   2   1   1   2   2   2   1   1   1   1   1   1

## Code Examples

### #1 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
var lines = input.split('\n');
let vetor = [];
let matriz = [];
for (let i = 0; i  <  contador / 2; i++) {
for (let j = 0; j  <  contador / 2; j++) {
const value = Math.min(i, j) + 1;
vetor[j] = value  <  10 ? ` \${value}` : `\${value}`;
vetor[contador - 1 - j] = vetor[j];
}
matriz[i] = ` \${vetor.join('  ')}`;
matriz[contador - 1 - i] = matriz[i];
}
console.log(`\${matriz.join('\n')}`);

console.log('');
}
``````
Copy The Code &

Input

cmd
1 2 3 4 5 0

Output

cmd
1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 1 1 1 1 1 1

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <iostream>
using namespace std;

int main(){
int n, i, j, mat[100][100] = {}, temp = 1;
bool is = false;
while(cin >> n and n != 0){
for (i = 0;i  <  n;i++) {
for (j = 0;j  <  n;j++) {
mat[i][j] = 1;
if (i > 0 and j > 0 and i  <  n-1 and j < n-1) {
mat[i][j] += mat[temp][temp];
}
if (j == i) {
is = true;
}
}
if(is == true){
temp+=1;
is = false;
}
}
for (i = 0;i < n;i++) {
for (j = 0;j  <  n;j++> {
cout << mat[i][j] << " ";
}
cout << endl;
}
}

return 0;
}
``````
Copy The Code &