vendredi 4 novembre 2022

I cannot get the idea what is logic to specific question in java

Question is simple 1.we need to take input of specific size 2.we need to print matrix of that size such that all odd number rows come top and even number rows come bottom like this in code shown below Input:5

OUTPUT:

1 2 3 4 5 - 1st row

11 12 13 14 15 - 3st row

21 22 23 24 25 - 5st row

6 7 8 9 10 - 2st row

16 17 18 19 20 - 4st row

I tried using for loops for the matrix but i cannot understand how to print number sequence inside the matrix and how can i print first all odd rows at top and even rows at bottom

https://i.imgur.com/iUJbDif.png

Aucun commentaire:

Enregistrer un commentaire