mardi 18 septembre 2018

About new line and space after last row and last column respectively

What I must get as output:
Example-1:

Input:
3

Output:
1\n
1 2\n
1 2 3

Example-2:

Input:
4

Output:
1\n
1 2\n
1 2 3\n
1 2 3 4

In the first example the input was 3. Hence there are 3 rows. The first row has element 1. The second row contains two elements 1 and 2 and the third row contains 1, 2 and 3 separated by a space.

What I actually get : Example 1 -  1 \n             Example 2 - 1 \n
                                   1 2 \n                       1 2 \n  
                                   1 2 3 \n                     1 2 3 \n
                                                                1 2 3 4 \n

There should not be any space after the each element of the last column and no new line after the last row.

Aucun commentaire:

Enregistrer un commentaire