top of page

소스 코드 제출

공개·회원 50명

20250621

/*

#include <stdio.h>

#include <stdlib.h>


int main()

{

printf("PRX WIN");

return 0;

}

*/

/*

#include <stdio.h>


int a[20][20]={};

int r=0;

void dfs(int x, int y, int z, int dir)

{

if(x>19 ||x<1 || y>19 || y<1 || a[x][y]!=z){

return ;

}

if(dir==1){

r++;

dfs(x+1, y, z, dir);

}

else if(dir==2){

dfs(x, y+1, z, dir);

r++;

}

else if(dir==3){

dfs(x+1, y+1, z, dir);

r++;

}

else if(dir==4){

dfs(x-1, y+1, z, dir);

r++;

}

}


int main()

{

int i, j, p=0;

for(i=1; i<=19; i++){

for(j=1; j<=19; j++){

scanf("%d", &a[i][j]);

}

}

for(i=1; i<=19; i++){

for(j=1; j<=19; j++){

if(a[i][j]==0) continue;

for(int k=1;k<=4;k++){

r=0;

if(k==1 && a[i-1][j]==a[i][j]){

continue;

}

else if(k==2 && a[i][j-1]==a[i][j]){

continue;

}

else if(k==3 && a[i-1][j-1]==a[i][j]){

continue;

}

else if(k==4 && a[i+1][j-1]==a[i][j]){

continue;

}

dfs(i, j, a[i][j], k);

if(r==5){

p++;

printf("%d\n", a[i][j]);

printf("%d %d", i, j);

}

}

}

}

if(p==0){

printf("0");

}

return 0;

}


*/


//캔디팡_BFS

#include <stdio.h>

#include <string.h>

int s, r=0, cnt=0, i, j;

int a[9][9]={};

char queue[9]={};

int front=-1, back=-1;


void push(int x)

{

back++;

queue[back]=x;

}


int pop()

{

if(back==front){

return 0;

}

front++;

return queue[front];


}


void bfs(int s)

{

a[i][j]=0;

for(i=1; i<=7; i++){

for(j=1; j<=7; j++){

if(a[i][j]==s){

}

}

}

}


int main()

{

for(i=1; i<=7; i++){

for(j=1; j<=7; j++){

scanf("%d", &a[i][j]);

}

}

for(i=1; i<=7; i++){

for(j=1; j<=7; j++){

if(a[i][j]!=0){

bfs(a[i][j]);

if(r>=3){

cnt++;

}

r=0;

}

}

}

printf("%d", cnt);

return 0;

}


//숫자 등고선

/*

#include <stdio.h>

int main()

{

return 0;

}

*/

//체스 말 이동

/*

#include <stdio.h>

int main()

{

return 0;

}

*/

//토마토_BFS

/*

#include <stdio.h>

int main()

{

return 0;

}

*/

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