profil

Sortowanie przez wybór - Turbo Pascal

poleca 84% 2849 głosów

Treść
Grafika
Filmy
Komentarze

program kolejnoscliczbprzezwybor;
uses crt;
var x:array[1..100] of integer;
min,a,i,e,s,d:integer;
begin
clrscr;
writeln(\'Podaj ile liczb podasz\');
readln(a);
writeln(\'Podaj \',a,\' liczb\');
for i:=1 to a do readln(x[i]);

for i:=1 to a do
begin
min:=x[i];
for d:=i to a do
begin
if min>x[d] then
begin
min:=x[d];
s:=d;
end;
end;
e:=x[i];x[i]:=x[s];x[s]:=e;
end;

writeln;
for i:=1 to a do writeln(x[i]);
readln;

end.

Czy tekst był przydatny? Tak Nie