Pagini recente » Cod sursa (job #2507750) | Cod sursa (job #266406) | Cod sursa (job #1398854) | Cod sursa (job #2286470) | Cod sursa (job #682028)
Cod sursa(job #682028)
program sortare;
var n,i,aux:longint;
x:array[1..500000] of longint;
f,g:text;
ok:boolean;
begin
assign(f,'algsort.in');
reset(f);
assign(g,'algsort.out');
rewrite(g);
read(f,n);
for i:=1 to n do begin
read(f,x[i]);
end;
repeat
ok:=true;
for i:=1 to n-1 do
begin
if x[i]>x[i+1] then begin aux:=x[i];
x[i]:=x[i+1];
x[i+1]:=aux;
ok:=false;
end;
end;
until ok=true;
for i:=1 to n do begin
write(g,x[i],' ');
end;
close(f);close(g);
end.