-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathc1097.java
More file actions
55 lines (46 loc) · 1.49 KB
/
c1097.java
File metadata and controls
55 lines (46 loc) · 1.49 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
package codeup100;
import java.util.Scanner;
public class c1097 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] arr = new int[19][19]; //2차원배열생성
//입력값 배열에 넣기
for(int i=0; i<arr.length; i++){
for(int j=0; j<arr.length; j++){
arr[i][j] = sc.nextInt();
//System.out.printf("%d ",arr[i][j]);
}
//System.out.println();
}
int count = sc.nextInt(); // 십자 뒤집기 횟수(n)
//1이면 0으로 0이면 1로
for(int n=0; n<count; n++){
int x = sc.nextInt()-1; //10 12
int y = sc.nextInt()-1; //10 12
//[10, i]가 0이면 1로, 1이면 0으로
for(int i=0; i<arr.length; i++){
if(arr[x][i] == 0){
arr[x][i] = 1;
}else{
arr[x][i] = 0;
}
}
//[j, 10]가 0이면 1로, 1이면 0으로
for(int j=0; j<arr.length; j++){
if(arr[j][y] == 0){
arr[j][y] = 1;
}else{
arr[j][y] = 0;
}
}
}
sc.close();
//답 출력
for(int i=0; i<arr.length; i++){
for(int j=0; j<arr.length; j++){
System.out.printf("%d ", arr[i][j]);
}
System.out.println();
}
}//end of main
}