-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP4for2017.java
More file actions
40 lines (34 loc) · 1012 Bytes
/
P4for2017.java
File metadata and controls
40 lines (34 loc) · 1012 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
public class P4for2017 {
public static void main(String[] args){
Position ps = new Position(5,6);
}
}
class Position{
private int role;
private int column;
public Position(int r, int c) {
this.role = r;
this.column = c;
}
public static Position findPosition(int num, int[][] intArr)
{
for(int r = 0; r < intArr.length; r++) {
for (int c = 0; c < intArr[0].length; c++) {
if (intArr[r][c] == num) {
return new Position(r, c);
}
}
}
return null;
}
public static Position[][] getSuccessorArray(int[][] intArr)
{
Position[][] successors = new Position[intArr.length][intArr[0].length];
for(int r = 0; r < successors.length; r++) {
for (int c = 0; c < successors[0].length; c++) {
successors[r][c] = findPosition(intArr[r][c] + 1, intArr);
}
}
return successors;
}
}