From 32461d9284de672a68f90770e6c5cfbdddd79a3d Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Thu, 3 Jul 2025 20:22:14 +0900 Subject: [PATCH] 20250703 baekjoon --- code_study/Baekjoon/c/11723.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 code_study/Baekjoon/c/11723.c diff --git a/code_study/Baekjoon/c/11723.c b/code_study/Baekjoon/c/11723.c new file mode 100644 index 0000000..df5eafd --- /dev/null +++ b/code_study/Baekjoon/c/11723.c @@ -0,0 +1,34 @@ +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include + +int main() { + int set = 0; + int N; + scanf("%d",&N); + getchar(); + while(N--) { + char str[20]; + if (fgets(str, sizeof(str), stdin) == NULL) break; + if (str[0] == '\n') { N++; continue; } + str[strcspn(str, "\n")] = 0; + char *opcode = strtok(str, " "); + char *operend = strtok(NULL, " "); + + if(!strcmp(opcode, "add")) { + set |= 1 << (atoi(operend)-1); + } else if(!strcmp(opcode, "remove")) { + set &= ~(1 << (atoi(operend)-1)); + } else if(!strcmp(opcode, "check")) { + printf("%d\n",set & (1 << (atoi(operend)-1)) ? 1 : 0); + } else if(!strcmp(opcode, "toggle")) { + set ^= 1 << (atoi(operend)-1); + } else if(!strcmp(opcode, "all")) { + set = (1<<20) - 1; + } else if(!strcmp(opcode, "empty")) { + set = 0; + } + } + return 0; +}