YouTube video link : click here Question link : click here
Solution : in Java
import java.util.Scanner;
public class BeautifulMatrix {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int arr[][] = new int[5][5];
boolean flag = false;
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
arr[i][j] = sc.nextInt();
}
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(arr[i][j]==1){
System.out.println(Math.abs(2-j)+Math.abs(2-i));
break;
}
}
if(flag){
break;
}
}
}
}
______________________________________________
Thanks for visiting
0 Comments