C 소스 인데 풀이 부탁드립니다 ㅜㅜ
딥체리
#include stdio.h
#define MAX_ELEMENT 100
typedef struct {
int heap[MAX_ELEMENT];
int heap_size;
} heapType;
heapType* createHeap()
{
heapType *h = (heapType *)malloc(sizeof(heapType));
h-heap_size=0;
return h;
}
void insertHeap(heapType *h, int item)
{
int i;
h-heap_size = h-heap_size +1;
i = h-heap_size;
while((i!=1) && (item h-heap[i/2])){
h-heap[i] = h-heap[i/2];
i/=2;
}
h-heap[i] = item;
}
int deleteHeap(heapType *h)
{
int parent, child;
int item, temp;
item = h-heap[1];
temp = h-heap[h-heap_size];
h-heap_size = h-heap_size -1;
parent = 1;
child = 2;
while(child = h-heap_size) {
if((child , h-heap_size) && (h-heap[child]) h-heap[child+1])
child++;
if (temp = h-heap[child]) break;
h-heap[parent] = h-heap[child];
parent = child;
child = child*2;
}
h-heap[parent] = temp;
return item;
}
printHeap(heapType *h)
{
int i;
printf(Heap : );
for(i=1; i= h-heap_size; i++){
printf([%d] , h-heap[i]);
}
}
void main()
{
int i, n, item;
heapType *heap = createHeap();
insertHeap(heap, 10);
insertHeap(heap, 45);
insertHeap(heap, 19);
insertHeap(heap, 11);
insertHeap(heap, 96);
printHeap(heap);
n= heap-heap_size;
for(i=1; i=n; i++){
item = deleteHeap(heap);
printf(\n delete : [%d] , item);
}
getchar();
}
C언어 초보자라 이해하기 힘들어요 ㅜㅜ 이해하는 데 도움을 주세요 !
-
한길찬
한줄 한줄은 아니더라도 풀이 부탁드려요 ^_^
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2698012 | 2~9가아닌수 | 아놀드 | 2025-06-13 |
2697980 | for에 gets함수를 넣으니까 왜 반복이 안되죠 ㅜ (2) | 펴라 | 2025-06-12 |
2697952 | 2차배열과 함수문의^^; | VanilLa | 2025-06-12 |
2697924 | 다차원 배열 질문있습니다 | 두동 | 2025-06-12 |
2697893 | 정올 :: 기초다지기 a9007 배열7 (문제가 이상함 -_-) | 흰두루 | 2025-06-12 |
2697862 | Unable......... 지정된 파일을 찾을 수 없습니다!! (1) | Creator | 2025-06-11 |
2697761 | 그러니까여제말은... (2) | 새론 | 2025-06-10 |
2697737 | 정올 문제좀 풀어보신분~ | 레오 | 2025-06-10 |
2697709 | rand함수 질문좀요! (6) | 가막새 | 2025-06-10 |
2697683 | C언어 변수뒤 표시가 이해안되는게 있습니다. | 소미 | 2025-06-10 |
2697660 | 껍데기딜 만들고 난후 어느핫키 누르면 코드검색이라도 뜨고 그다음 무반응 해결좀 (2) | 움찬 | 2025-06-09 |
2697634 | c언어로 감성사전 만들기! (1) | 도란도란 | 2025-06-09 |
2697605 | 이 함수좀... | agine | 2025-06-09 |
2697574 | 배열 기본적인질문 (3) | 민트향 | 2025-06-09 |
2697549 | 배열 초기화 (4) | 나리 | 2025-06-08 |
2697465 | 수다님...^^ (2) | 가론 | 2025-06-08 |
2697432 | 서버 만드는 함수에서 궁금한게있어요~ | 파랑 | 2025-06-07 |
2697401 | 열혈강의 문제오류 (1) | 꿈 | 2025-06-07 |
2697374 | 기초적인 C언어 프로그래밍 입니다. | 얼 | 2025-06-07 |
2697341 | 좌우대칭 문제인데 Q가 입력되면 종료가 되야하는데 되지않습니다 | 무지개 | 2025-06-07 |