-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA 263 - Beautiful Matrix.java
More file actions
43 lines (36 loc) · 952 Bytes
/
A 263 - Beautiful Matrix.java
File metadata and controls
43 lines (36 loc) · 952 Bytes
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
43
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] data = new int[5][5];
int x = 0, y = 0, count = 0;
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
data[i][j] = input.nextInt();
if (data[i][j] == 1) {
x = i + 1;
y = j + 1;
}
}
}
while (x != 3) {
if (x > 3) {
x--;
count++;
} else if (x < 3) {
x++;
count++;
}
}
while (y != 3) {
if (y > 3) {
y--;
count++;
} else if (y < 3) {
y++;
count++;
}
}
System.out.println(count);
}
}