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