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)); } } } }
}
Discover more from Coursity
Subscribe to get the latest posts sent to your email.