A. Beautiful Matrix // Solution in java

import java.util.Scanner; public class Problem { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[][] nums = new int[5][5]; for(int i = 0; i < nums.length; i++) { for(int j = 0; j < nums.length; j++) { nums[i][j] = input.nextInt(); } } for(int i = 0; i < nums.length; i++) { for(int j = 0; j < nums.length; j++) { if(nums[i][j] == 1) { System.out.println(Math.abs(i-2) + Math.abs(j-2)); } } } }
} 
Enter fullscreen mode
Exit fullscreen mode

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Best food delivery apps – menu with price. What is social media advertising and how can it benefit my business ?. If there are enough subscribers to the list, we will do our best to expedite the selected dc location plans.