void heap_sort(int list[], int n)
{
 int *heap,i,j,t;
 heap=(int*)malloc(sizeof(int)*(n+1));

 for(i=0; i<n;i++)
 {
  heap[i+1]=list[i];
  j=i+1;
  while(j!=1 && heap[j/2]>heap[j])
  {
   t=heap[j/2];
   heap[j/2]=heap[j];
   heap[j]=t;
   j/=2;
  }
 }

 for(i=0;i<n;i++)
 {
  list[i]=heap[1];
  heap[1]=heap[n-i];
  j=1;

  while(j*2<n-i)
  {
   if(j*2+1<n-i)//자식이 둘인경우
   {
    if(heap[j*2+1]<heap[j*2])//오른자식이작은경우
    {
     if(heap[j*2+1]<heap[i])//오른자식보다ㄷ 부모가 큰경우
     {
      t=heap[j*2+1];
      heap[j*2+1]=heap[j];
      heap[j]=t;
      j=j*2+1;
     }
     else
      break;
    }
    //if(heap[j*2+1]>heap[j*2])
    else if(heap[j*2]<heap[j])//왼쪽자식이 오른쪽자식보다 큰경우 왼쪽자식보다 부모가 큰 경우
    {
     t=heap[j*2];
     heap[j*2]=heap[j];
     heap[j]=t;
     j*=2;
    }
    else
     break;
   }
   else if(heap[j*2]<heap[j])//자식이 하나인 경우 자식이 부모보다 작으면
   {
    t=heap[j*2];
    heap[j*2]=heap[j];
    heap[j]=t;
    j*=2;
   }
   else
    break;
  }
 }
 free(heap);
}


배열이 10일때 한두개정도 정렬이안되고(1 7 4 0 9 4 8 8 2 4 -> 0 1 2 4 8 4 4 7 8 9
)
100개가되면 정렬이안되는게 재곱수로 많아지내요

프갤성님들 도와주세요