From c7f43cf7bcfaebf65b47c981dacbe4e56e34f5ec Mon Sep 17 00:00:00 2001 From: Sanghun Park Date: Sun, 28 Sep 2025 18:46:16 +0900 Subject: [PATCH] =?UTF-8?q?[feat]:=20BOJ2606=20=EB=B0=94=EC=9D=B4=EB=9F=AC?= =?UTF-8?q?=EC=8A=A4=20=EA=B5=AC=ED=98=84(DFS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Devil_C/week04_dfs/sanghun/BOJ_2606.c | 49 +++++++++++++++++++++++++++ Devil_C/week04_dfs/sanghun/filename.c | 0 2 files changed, 49 insertions(+) create mode 100644 Devil_C/week04_dfs/sanghun/BOJ_2606.c delete mode 100644 Devil_C/week04_dfs/sanghun/filename.c diff --git a/Devil_C/week04_dfs/sanghun/BOJ_2606.c b/Devil_C/week04_dfs/sanghun/BOJ_2606.c new file mode 100644 index 0000000..754525d --- /dev/null +++ b/Devil_C/week04_dfs/sanghun/BOJ_2606.c @@ -0,0 +1,49 @@ +#include +#include + +struct virus{ + int node; + struct virus* next; +}; + +struct virus* graph[101]; + +void network(int u, int v){ + struct virus *vir; + vir = (struct virus*)malloc(sizeof(struct virus)); + vir -> node = v; + vir -> next = graph[u]; + graph[u] = vir; +} + +int visited[101]; +int count = 0; +void dfs(int start){ + visited[start] = 1; + count ++; + struct virus* current = graph[start]; + while(current != NULL){ + if(!visited[current -> node]){ + dfs(current -> node); + } + current = current -> next; + } + return; +} + +int main(){ + int com; + int num; + scanf("%d %d", &com, &num); + + for(int i=0; i