// 1️⃣ (방향 이동 연습)

// 다음 3×3 배열이 있다.

// 1 1 0
// 0 1 0
// 1 0 1

// (1,1)에서 상하좌우로 갈 수 있는 좌표를 모두 쓰시오.
// (단, 배열 범위 안에서만)



// 2️⃣ (범위 체크 코드 완성)

// 다음 코드를 완성하시오.

int n = 3;
int x = 1, y = 1;

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

for(int k=0;k<4;k++){
    int nx = x + dx[k];
    int ny = y + dy[k];

    if( __________________ ){
        cout << nx << " " << ny << "\n";
    }
}


// 덩어리는 몇 개인가?

// 1 1 0 0
// 0 1 0 1
// 0 0 0 1
// 1 0 0 0

Embed on website

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