Pagini recente » Clasamentul arhivei educationale | Borderou de evaluare (job #1248892) | Borderou de evaluare (job #1489717) | Cod sursa (job #558776) | Cod sursa (job #260338)
Cod sursa(job #260338)
var a:array[1..500000] of longint;
n,i,j:longint;
procedure Sort(l, r: longint);
var
i, j, x, y: longint;
begin
i := l; j := r; x := a[(l+r) DIV 2];
repeat
while a[i] < x do i := i + 1;
while x < a[j] do j := j - 1;
if i <= j then
begin
y := a[i]; a[i] := a[j]; a[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort(l, j);
if i < r then Sort(i, r);
end;
begin
assign(input,'algsort.in');
assign(output,'algsort.out');
reset(input);
rewrite(output);
read(N);
for i:=1 to n do
read(a[i]);
sort(1,N);
for i:=1 to n do
write(a[i],' ');
close(input);
close(output);
end.