Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program sortowaniebabelkowe;
- 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
- writeln;writeln;
- Write(i, ' wykonanie petli: ');
- for j := 1 to ilosc - 1 do
- begin
- writeln;
- for pom :=1 to ilosc do begin
- if pom = j then write('(',tab[pom],' ')
- else if pom = j+1 then write(tab[pom], ') ')
- else write(tab[pom], ' ');
- end;
- //writeln;
- 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;
- writeln;
- for pom :=1 to ilosc do begin
- write(tab[pom], ' ');
- 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