Xin sửa lổi dùm mình! Mình cai hoài mà không được![IMG]images/smilies/icon_question.gif[/IMG][IMG]images/smilies/21.gif[/IMG]
xin giúp đỡ ,cảm ơn nhiều. code dậy:

Mã:
# include <stdio.h># include <conio.h>const int max=1000; int a[max],n; void nhap(); void xuat(); void heapsort(int a[]); main() {    nhap();    heapsort(a);     xuat();   }  void nhap()    {      scanf("%d",&n);      for(int i=0;i<n;i++) scanf("%d",&a[i]);  }    void xuat() {      for(int i=0;i<n;i++) printf("%d ",a[i]);      getch();       }  void adjust(int a[],int root,int endnote) {      int key,c;      key=a[root];      while(root*2<=endnote)      {         c=root*2;         if(c<endnote&&a[c]<a[c+1]) c++;         if (key>=a[c]) break;         a[root]=a[c];         root=c;      }      a[root]=key;                        }  void doi(int *x,int *y) {      int z;      z=*x;      *x=*y;      *y=z;  } void  heapsort(int a[]) {       for(int r=(n-1)/2;r>=0;r--) adjust(a,r,n);       for(int i=n-1;i>0;i--)       {           doi(&a[i],&a[0]);           adjust(a,1,i-1);                   }       }