program QuickSort;
uses wincrt;
const
n=100;
type
A = array [1..n] of integer;
procedure quicksortasc (var n:integer; var S:A);
var
U,V:A;
pivot, i, j, high, low, temp, h, m: integer;
stop: boolean;
begin
if n > 1 then
begin
pivot:= (n div 2) +1;
stop:=true;
while stop do
begin
i:=1;
high:=pivot;
while (i<pivot) and (high=pivot) do
begin
if S[i] > S[pivot] then
high:= i
else
i:=i+1;
end;
j:=n;
low:=pivot;
while (j>pivot) and (low=pivot) do
begin
if S[j] < S[pivot] then
low:= j
else
j:=j-1;
end;
if high = low then
stop:= false
else
begin
temp:=S[low];
S[low]:=S[high];
S[high]:=temp;
end;
end;
h:= pivot-1;
m:= n-(h+1);
for i:=1 to h do
begin
U[i]:= S[i];
end;
j:=h+1;
for i:=1 to m do
begin
V[i]:= S[j];
j:=j+1;
end;
quicksortasc(h,U);
quicksortasc(m,V);
for i:=1 to h do
begin
S[i]:=U[i];
end;
j:=h+1;
for i:=1 to m do
begin
S[j]:= V[i];
j:=j+1;
end;
end;
end;
var
S:A;
i,t: integer;
BEGIN
Write('Masukkan jumlah data: ');
Readln(t);
for i:= 1 to t do
begin
Write (i,') ');
Readln(S[i]);
end;
quicksortasc(t,S);
Write('Data sekarang: ');
for i:= 1 to t do
begin
Write(S[i]:2);
end;
END.
Langganan:
Posting Komentar (Atom)
Merkur 37C Review: Is this an easy-to-use Safety Razor?
BalasHapusMerkur 37C is a worrione great razor but I have not been able to beat the Merkur 37C, but it's not perfect for a beginner, and I'm not going to make this razor Pros and cons include: Very good looking ⋅ Excellent all-around head ⋅ Handshaving brush ⋅ Excellent for beginners ⋅ Handle is too coarse and heavy for a beginner · Overall Pros and 메리트카지노 cons include: Well-designed 바카라 ⋅ Good handle ⋅ Handshaving brush ⋅ Excellent for beginners