0

How to print all hourglasses of a given matrix using for loops in Java?

You can also use different loops.(for is preferred) Sample Input: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 2 4 4 0 0 0 0 2 0 0 0 0 1 2 4 0 Output: 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 2 0 2 4 2 4 4 4 4 0 1 1 1 1 1 0 1 0 0 0 0 0 0 2 4 4 0 0 0 0 0 2 0 2 0 2 0 0 0 0 2 0 2 4 2 4 4 4 4 0 0 0 2 0 0 0 1 0 1 2 1 2 4 2 4 0

5th Jun 2018, 9:37 AM
Rajesh Nayak
Rajesh Nayak - avatar
1 Odpowiedź
+ 3
I didn't want to code it for you, but figured you'd be able to understand this code and write your own in Java. This code can do any size matrix from 3x3 up, though the formatting fails at 10x10. https://code.sololearn.com/cuwRYKUdRhuA
5th Jun 2018, 12:59 PM
John Wells
John Wells - avatar