profil

Porządkowanie przez wybór - Turbo Pascal

poleca 85% 107 głosów

Treść
Grafika
Filmy
Komentarze

PORZADKOWANIE PRZEZ WYBOR:

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;
if s<>0 then begin e:=x[i];x[i]:=x[s];x[s]:=e;end;
end;

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

end.

Czy tekst był przydatny? Tak Nie