leejaeheon446 / team_project

0 stars 1 forks source link

Datastructure.md #4

Closed baljaa1234 closed 4 years ago

baljaa1234 commented 4 years ago

#include <stdio.h>
int number = 9;
int heap[9] = {7, 6, 5, 8, 3, 5, 9, 1, 6};
int main(void)
{
for(int I = 1; i < number; I++)
{
int c = I;
do{
int root = (c - 1)/ 2;
if(heap[root] < heap[c] )
{
int temp = heap[root];
heap[root] = heap[c];
heap[c] = temp;
}
c = root;
} while (c !=0);
}