-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathc1099.java
More file actions
63 lines (52 loc) ยท 1.64 KB
/
Copy pathc1099.java
File metadata and controls
63 lines (52 loc) ยท 1.64 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package codeup100;
import java.util.Scanner;
public class c1099 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//๊ฐ๋ฏธ์ง 10*10
int[][] antHouse = new int[11][11];
//๊ฐ๋ฏธ์ง์ ์
๋ ฅ๊ฐ ๋ฃ๊ธฐ
int w;
for(int i=1; i<antHouse.length; i++){
for(int j=1; j<antHouse.length; j++){
w = sc.nextInt();
antHouse[i][j] = w;
}
}
//์ค๋ฅธ์ชฝ ์๋๋ก ๋ด๋ ค๊ฐ์์๋๋ก count๋ณ์๋ก y์ขํ ๊ธฐ์ตํ๊ธฐ
int count = 2;
Boolean isTwo = false;
for(int i=2; i<11; i++){
for(int j=count; j<11; j++) {
System.out.println("์ขํ(x,y)๋ ("+ i +" , "+ j + ") ๊ฐ์?"+antHouse[i][j]);
//๋จน์ด(2)์ธ ๊ฒฝ์ฐ
if (antHouse[i][j] == 2) {
isTwo = true;
antHouse[i][j] = 9;
break;
}
//๊ฐ ์ ์๋ ๊ธธ(0)์ธ ๊ฒฝ์ฐ
if (antHouse[i][j] == 0) {
antHouse[i][j] = 9;
}
//๋ฒฝ(1)์ธ ๊ฒฝ์ฐ
else if (antHouse[i][j] == 1) {
count = j-1;
break;
}
}
//๋จน์ด(2)์ธ ๊ฒฝ์ฐ
if(isTwo) {
break;
}
}
sc.close();
//์ถ๋ ฅ
for(int i=1; i<antHouse.length; i++){
for(int j=1; j<antHouse.length; j++){
System.out.printf("%d ", antHouse[i][j]);
}
System.out.println();
}
}
}