program exchange_sort;
uses Crt;
var i,j,N,pom,min,minimum : integer;
    a : array [1..100] of integer;
begin
  Clrscr;
  randomize;
  write('Zadaj pocet prvkov pola: ');
  readln(N);
  for i:= 1 to N do begin
    a[i]:= random(100)+1; write(a[i],'  ');
  end;
  writeln;
  for i:=1 to N-1 do begin
    min:=i;
    minimum:=200;
    for j:=i+1 to N do
      if minimum>a[j] then begin
        minimum:=a[j];
        min:=j;
      end;
    if a[i]>minimum then begin
      pom:=a[i]; a[i]:=a[min]; a[min]:=pom;
    end;
  end;
  writeln('zoradene to je takto:');
  for i:=1 to N do write(a[i],'  ');
  readln;
end.
