Pagini recente » Cod sursa (job #663315) | Cod sursa (job #2194426) | Cod sursa (job #2493998) | Cod sursa (job #341272) | Cod sursa (job #262967)
Cod sursa(job #262967)
type list=array[1..500000]of longint;
var Data:list;
n,i:longint;
f:text;
procedure qSort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=data[(l+r) DIV 2];
repeat
while data[i]<x do inc(i);
while x<data[j] do dec(j);
if i<=j then begin
y:=data[i];
data[i]:=data[j];
data[j]:=y;
inc(i); dec(j);
end;
until i > j;
if l<j then qSort(l, j);
if i<r then qSort(i, r);
end;
begin
assign(f,'algsort.in');reset(f);
read(f,n);
for i := 1 to n do read(f,data[i]);
close(f);
qSort(1,n);
assign(f,'algsort.out');rewrite(f);
for i:=1 to n do Write(f,Data[i],' ');
close(f);
end.