A. Beautiful Matrix
Solution :
import java.util.Scanner;
public class BeautifulMatrix {
public static void main(String[] args) {
int n = 0,m = 0;
Scanner sc = new Scanner(System.in);
for(int i=0;i<5;i++) {
for(int j=0;j<5;j++) {
if(sc.nextInt()==1) {
n=i;
m=j;
}
}
}
System.out.println(Math.abs(2-n)+Math.abs(2-m));
sc.close();
}
}
0 comments:
Do not spam here.