Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 4208dc4

Browse files
authored
Add files via upload
1 parent a1476e1 commit 4208dc4

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

Java/bin/Position.class

0 Bytes
Binary file not shown.

Java/bin/Structure.class

0 Bytes
Binary file not shown.

Java/bin/perimeter.class

117 Bytes
Binary file not shown.

Java/perimeter.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13 22
1+
16 27

Java/src/perimeter.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ public static Structure flood(int x,int y, int i) {
2424
int x1 = p.x;
2525
int y1 = p.y;
2626
try {
27-
if(grid[x1][y1]) {
28-
//System.out.println("FILL ("+x1+","+y1+")");
29-
if(x1 < N ) {
30-
q.add(new Position(x1 + 1,y1));
31-
}
32-
if(0 < x1) {
33-
q.add(new Position(x1 - 1,y1));
27+
28+
System.out.println("FILL ("+x1+","+y1+")");
29+
if(grid[x1][y1]) {
30+
if(x1 < N && grid[x1 + 1][y1]) {
31+
q.add(new Position(x1 + 1,y1));
32+
}
33+
if(1 < x1 && grid[x1 - 1][y1]) {
34+
q.add(new Position(x1 - 1,y1));
35+
}
36+
if(y1 < N && grid[x1][y1 + 1]) {
37+
q.add(new Position(x1,y1 + 1));
38+
}
39+
if(1 < y1 && grid[x1][y1 - 1]) {
40+
q.add(new Position(x1,y1 - 1));
41+
}
3442
}
35-
q.add(new Position(x1,y1 + 1));
36-
q.add(new Position(x1,y1 - 1));
37-
}else {
38-
continue;
39-
}
4043
}catch(Exception ex) {
4144
continue;
4245
}
@@ -69,7 +72,7 @@ public static void main(String[] args) throws IOException{
6972
if(grid[i][j] == true) {
7073
numStructs ++;
7174
Structure st = flood(i, j, numStructs);
72-
st.toggleAll();
75+
//st.toggleAll();
7376
//st.perimeterList.removeAll(st.posList);
7477

7578
st.perimeterList.removeAll(st.posList);

0 commit comments

Comments
 (0)