Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program sortowanie;
- uses crt;
- var
- tab:array[1..100] of integer;
- i,j,ilosc,pom:integer;
- begin
- clrscr;
- write('Z ilu elementow ma skladac sie ciag liczb: ');
- readln(ilosc);
- if ilosc <=0 then
- begin
- repeat
- writeln('podaj DODATNIA wartosc dla ciagu');
- readln(ilosc);
- until ilosc>0;
- end;
- for i:=1 to ilosc do
- begin
- write('Podaj ', i, ' element ciagu: ');
- readln(tab[i]);
- end;
- writeln;
- write('Ciag nieposortowany: ');
- for i:=1 to ilosc do
- write(tab[i], ' ');
- writeln;writeln;
- for i:=1 to ilosc-1 do
- begin
- write( i, ' wykonanie petli: ');
- for j:=1 to ilosc-1 do
- begin
- if tab[j]>tab[j+1] then
- begin
- pom:=tab[j];
- tab[j]:=tab[j+1];
- tab[j+1]:=pom;
- end;
- write(tab[j], ' ');
- end;
- write(tab[j+1]);
- writeln;
- end;
- writeln;
- writeln;
- write('Ciag posortowany: ');
- for i:=1 to ilosc do
- write(tab[i], ' ');
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement