8000 Create 11723_1.cpp · hackerman91/basic-algo-lecture@11db16d · GitHub
[go: up one dir, main page]

Skip to content

Commit 11db16d

Browse files
Create 11723_1.cpp
1 parent 2cdcc3f commit 11db16d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Appendix C/11723_1.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// http://boj.kr/1febea8e97bb4493925075f36d6efb8d
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
int chk[20];
6+
7+
int main(){
8+
ios::sync_with_stdio(0);
9+
cin.tie(0);
10+
11+
int m;
12+
cin >> m;
13+
while(m--){
14+
string com;
15+
int x;
16+
cin >> com;
17+
if(com == "add"){
18+
cin >> x;
19+
chk[x-1] = 1;
20+
}
21+
else if(com == "remove"){
22+
cin >> x;
23+
chk[x-1] = 0;
24+
}
25+
else if(com == "check"){
26+
cin >> x;
27+
cout << chk[x-1] << '\n';
28+
}
29+
else if(com == "toggle"){
30+
cin >> x;
31+
chk[x-1] = 1 ^ chk[x-1];
32+
}
33+
else if(com == "all"){
34+
fill(chk, chk+20, 1);
35+
}
36+
else{ // empty
37+
fill(chk, chk+20, 0);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)
0