void creat_heap(int* arr,size_t root,size_t len)
{
if(root >= len) return;
int left = root*2+1,right = root*2+2;
creat_heap(arr,left,len);
creat_heap(arr,right,len);
int max = root;
if(left < len)
{
if(arr[left] > arr[max])
max = left;
}
if(right < len)
{
if(arr[right] > arr[max])
max = right;
}
if(max != root)
swap(arr[max],arr[root]);
}
void heap_sort(int* arr,size_t len)
{
for(int i=0; i<len; i++)
{
creat_heap(arr,0,len-i);
swap(arr[0],arr[len-i-1]);
}
}