-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeautifulMatrix.java
42 lines (38 loc) · 1.01 KB
/
BeautifulMatrix.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.Arrays;
import java.util.Scanner;
public class BeautifulMatrix {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[][] a=new int[5][5];
for(int i=0;i<5;i++){
for (int j=0;j<5;j++){
a[i][j]=s.nextInt();
}
}
int currentRow=0;
int currentColumn=0;
for(int i=0;i <5; i++)
{
for(int j = 0;j < 5; j++)
{
if(a[i][j]==1){
currentRow=i;
currentColumn=j;
// a[i][j]=0;
// a[2][2]=1;
break;
}
}
}
System.out.println(Math.abs(currentRow-2)+Math.abs(currentColumn-2));
// for(int z = 0; z <5; z++)
// {
// for(int y = 0; y < 5; y++)
// {
// System.out.print(a[z][y]);
// }
// System.out.println();
// }
s.close();
}
}