#include <stdio.h>

#include <stdlib.h>


typedef struct HeapTag {//힙의 개념

int* array;

int count; // 힙 안의 항목 개수

int capacity; // 힙의 용량

int heap_type; //힙의 종류

}Heap;


Heap* CreateHeap(int capacity, int heap_type) {

Heap* h = (Heap*)malloc(sizeof(Heap));

if (h == NULL) {

printf("Memory Error");

return ;

}

h->heap_type = heap_type;

h->count = 0;

h->capacity = capacity;

h->array = (int*)malloc(sizeof(int) * h->capacity);

if (h->array == NULL) {

printf("Memory Error");

return ;

}

return h;

}


int Parent(Heap* h, int i) {

if (i <= 0 || i >= h->count)

return -1;

return (i - 1) / 2;

}


int LeftChild(Heap* h, int i) {

int left = 2 * i + 1;

if (left >= h->count)

return -1;

return left;

}


int RightChild(Heap* h, int i) {

int right = 2 * i + 2;

if (right >= h->count)

return -1;

return right;

}


void PercolateDown(Heap* h, int i) {

int l, r, max, temp;

l = LeftChild(h, i);

r = RightChild(h, i);


if (l != -1 && h->array[l] > h->array[i]) max = l;

else max = i;

if (r != -1 && h->array[r] > h->array[max]) max = r;


if (max != i) {

temp = h->array[i];

h->array[i] = h->array[max];

h->array[max] = temp;

PercolateDown(h, max);

}

}


int DeleteMax(Heap* h)

{

int data;

if (h->count ==0)

return -1;

data = h->array[0];

h->array[0]=h->array[h->count-1];

h->count--;

PercolateDown(h,0);

return data; 

}


void PercolateUp(Heap* h, int i) {//여기서 오류남

int p, max, temp;

p = Parent(h, i);

if (p != -1 && h->array[p] > h->array[i]) max = p;

else max = i;


if (max != p) {

temp = h->array[p];

h->array[p] = h->array[max];

h->array[max] = temp;

PercolateUp(h, max);

}

}


void Insert(Heap* h,int data) {

int i;

i = ++(h->count);

if (i > h->capacity) {

(h->capacity)++;

}

h->array[i] = data;

PercolateUp(h, i);

}


int main() {

int i, n, item, max;

Heap * h = CreateHeap(5, 1);

Insert(h, 10);

Insert(h, 45);

Insert(h, 19);

Insert(h, 11);

Insert(h, 96);


max = DeleteMax(h);

printf("\n MaxNumber : %d", max);

return 0;

}

79번째 줄 (PercolateUp 함수임)에서 

C1075 '{':일치하는 토큰을 찾을 수 없습니다.

이렇게 뜨는데 이유가 뭐임

{}이거 제대로 안썻다는거 같은데 ㅄ이라 못찾고 있음