OUTTEXTXY10,2,'Chuong trinh HeapSort'; VEKHUNG1A; SETTEXTSTYLEDEFAULTFONT,HORIZDIR,1;... Ob_ject.Menuchinh;Closegraph; readln;END.
Trang 2if k=0 then j:=850;
settextstyle(2,0,6);
setcolor(15);
outtextxy(j,420,'Nhan Phim Bat Ky de Tiep Tuc ');
outtextxy(k,420,'Nhan Phim Bat Ky De Tiep Tuc ');
delay(10);
duongchay(0,422,getmaxx,439,1);
until (keypressed) or (i>1500);
if i>5 then exit;
writeln('Mang can sap co ',n,' phan tu:');
writeln('Gia tri cua cac phan tu 3<a[i]<=30:');
Trang 3until (a[i]>3) and (a[i]<=30);
end;
clrscr;
writeln('Mang can sap co ',n,' phan tu:'); writeln;
for j:=1 to i do writeln('a[',j,']= ',a[j]);
Trang 4outtextxy(150,450,'An phim bat ky de tiep tuc, Esc de thoat !');for i:= 1 to n do
Trang 6outtextxy(100,300,'An phim bat ky de tiep tuc,');
outtextxy(100,320,'An Esc de thoat !');
Trang 7for i:=n downto 1 do
outtextxy(100,300,'An phim bat ky de tiep tuc,');
outtextxy(100,320,'An Esc de thoat !');
setcolor(15);
outtextxy(80,280,'Mang da duoc sap xep.');
outtextxy(80,300,'An Enter de ve menu chinh !');
Trang 9end;
end;
xoa(100,200,30);
for i:=1 to n do xoa(tamx[i],tamy[i],30);
for i:=1 to n do tron(tamx[i],tamy[i],b[i]);
Trang 13GETMEM(Q,L);
GETIMAGE(X1-R2,Y1-R1,X1+R2,Y1+R1,P^);GETIMAGE(X2-R2,Y2-R1,X2+R2,Y2+R1,Q^);
Trang 15OUTTEXTXY(10,2,'Chuong trinh HeapSort');
VEKHUNG1(A);
SETTEXTSTYLE(DEFAULTFONT,HORIZDIR,1);
Trang 16line(tamx[i], tamy[i], tamx[2*i], tamy[2*i]);
if 2*i<n then line(tamx[i], tamy[i], tamx[2*i+1], tamy[2*i+1]);
end;
end;
Procedure Heap_sort(var x:mang; p:integer);
var
Trang 18xoa(tamx[i div 2],tamy[i div 2],x[i div 2]);
line(tamx[i],tamy[i],tamx[i div 2], tamy[i div 2]);
Trang 19tron(tamx[i div 2],tamy[i div 2],x[i div 2]);
for i:=2 to 3 do begin tamx[i]:=i*220-140; tamy[i]:=150; end;
for i:=4 to 7 do begin tamx[i]:=i*120-260; tamy[i]:=220; end;
for i:=8 to n do begin tamx[i]:=(i-1)*100-550;tamy[i]:=320; end;
dt; for i:=1 to n do tron(tamx[i],tamy[i],Item[i]);
Trang 24outtextxy(150,210,'GOOBYE, SEE YOU AGAIN !');
Phim[1]:=' Selection Sort ';
Phim[2]:=' Insertion Sort ';
Phim[3]:=' Bubble Sort ';
Phim[4]:=' Shell Sort ';
Phim[5]:=' Quick Sort ';
Phim[6]:=' Heap Sort ';
Phim[7]:=' Merge Sort ';
Phim:=' Exit ';
while (chon<>8) do
begin
obj.Move(8,230,80,380,110,4,true,phim,3,7,yellow,green,chon);
if chon=1 then Selection;
if chon=2 then Insertion;
if chon=3 then Bubble;
if chon=4 then Shellsort;
if chon=5 then Quick;
if chon=6 then Heapsort;
if chon=7 then Mergesort;
if (chon=8) and (ok) then
Trang 25Ob_ject.Menuchinh;Closegraph; readln;END