/*
[문제 3] 영역 개수 구하기

전체 배열에서 1로 이루어진 영역이 몇 개인지 구하시오.

[입력]
5 5
1 1 0 0 0
0 1 0 1 1
0 0 0 1 0
1 1 0 0 0
0 0 0 0 1

[출력]
4
*/

#include <iostream>
using namespace std;

int map[5][5];
int visited[5][5];

int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

void dfs(int x, int y){
    // TODO
}

int main(){
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            cin >> map[i][j];
        }
    }

    int count = 0;

    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            // TODO: 방문 안했고 1이면
            // dfs 호출 + count 증가
        }
    }

    cout << count;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: