Pagini recente » Cod sursa (job #2339661) | Cod sursa (job #2759225) | Cod sursa (job #378179) | Cod sursa (job #2280194) | Cod sursa (job #875553)
Cod sursa(job #875553)
var bufin,bufout:array[1..65000]of byte;
n,i,max,imax,t,j:longint;
a:array[1..500001]of longint;
ok:boolean;
begin
assign(input,'algsort.in'); reset(input);
assign(output,'algsort.out'); rewrite(output);
settextbuf(input,bufin);
settextbuf(output,bufout);
readln(n);
for i := 1 to n do read(a[i]);
for i := 1 to n-1 do
begin
max := a[i];
imax := i;
ok := true;
for j := i+1 to n do
begin
if max > a[j] then
begin
max := a[j];
imax := j;
ok := false;
end;
end;
if ok = false then
begin
t := a[i];
a[i] := max;
a[imax] := t;
end;
end;
for i := 1 to n do write(a[i],' ');
close(input);
close(output);
end.