경북대학교 알고리즘 미로만들기 c언어 소스코드입니다.(백준 2665 변형)
- 최초 등록일
- 2021.05.13
- 최종 저작일
- 2021.05
- 5페이지/ 한컴오피스
- 가격 2,500원
소개글
백준 2665번 문제가 변형된 미로 만들기 알고리즘 c언어로 구현한 소스코드입니다.
경북대학교 알고리즘 과제로 제출한 내용입니다.
2665번 문제에서 경로를 출력하는 부분이 추가되었습니다.
목차
없음
본문내용
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
typedef struct {
int x; int y; int px; int py; int value;
} heapNode;
typedef struct
{ heapNode* heap; int size; } PQ;
FILE* fp2;
int** visit;
int** map;
int*** path;
int** c;
int N;
PQ q;
int DIR[4][2] = { {1,0},{0,1},{-1,0},{0,-1} };
void insert(heapNode aNode, heapNode* heap, int size)
{
int idx;
heapNode temp;
idx = size + 1;
heap[idx] = aNode;
while (heap[idx].value < heap[idx/2].value && idx > 1)
{
temp = heap[idx];
heap[idx] = heap[idx/2];
heap[idx/2] = temp;
idx /= 2;
}
}
void shiftdown(heapNode* heap, int size, int idx)
{
int cidx;
heapNode tmp;
while(1)
{
cidx = idx*2;
if (cidx > size)
{
break;
}
if (cidx < size)
{
if (heap[cidx].value > heap[cidx+1].value)
{
++cidx;
}
}
if (heap[cidx].value < heap[idx].value)
참고 자료
없음