Pagini recente » Cod sursa (job #1981984) | Cod sursa (job #2658130) | Cod sursa (job #67446) | Cod sursa (job #3213913) | Cod sursa (job #682006)
Cod sursa(job #682006)
program sortare;
var n,i,aux:longint;
x:array[1..100] 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.