top of page

소스 코드 제출

공개·회원 50명

250720


#include <stdio.h>

int q[2][10001]={};

int s=0, e=0;

int n;

int x, y, px, py;

int c=1;

int arr[101][101]={};


void view()

{

printf("queue \n");

for(int i= s;i<e;i++)

printf("%d ",q[0][i]);

printf("\n");

for(int i= s;i<e;i++)

printf("%d ",q[1][i]);

printf("\n");

}


void push(int px, int py)

{

if (px>n || py>n || px<1 || py<1 || arr[px][py]!=0)

{

return;

}

q[0][e]=px;

q[1][e]=py;

arr[px][py]=c;

e++;

}

void pop()

{

s++;

px = q[0][s-1];

py = q[1][s-1];

}


int main()

{

scanf("%d", &n);

scanf("%d %d", &x, &y);

push (x, y);

while (s!=e)

{

pop();

push(px+1, py);

push(px-1, py);

push(px, py+1);

push(px, py-1);

// view();

}

for (int i=1 ; i<=n ; i++)

{

printf("\n");

for (int j=1 ; j<=n ; j++)

{

printf("%d ", arr[i][j]);

}

}

}


4회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page