Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program sortowanie;
- uses crt;
- var
- nizej,typLosowania,ify1,ify2,petle1,petle2 : byte;
- jeszczeraz : char;
- tab : array[1..10]of byte;
- tabd : array[1..10]of byte;
- procedure losuj;
- var x : byte;
- begin randomize;
- for x:=1 to 10 do begin
- tab[x]:=random(10);
- tabd[x]:=tab[x]; end;
- end;
- procedure wyswietl;
- var x : byte;
- begin
- for x:=1 to 10 do begin
- gotoxy(x+x,1+nizej);write(tab[x],' ');gotoxy(x+x+35,1+nizej);write(tabd[x],' ');end;
- end;
- procedure sortowanieBabelkowe;
- var x,y,t,schowek : byte;
- begin
- for y:=1 to 9 do begin
- for x:=1 to 9 do begin
- petle1:=petlee1+1;
- if typLosowania=1 then begin
- if tab[x]>tab[x+1] then begin
- ify1:=ify1+1;
- schowek:=tab[x+1];tab[x+1]:=tab[x];tab[x]:=schowek;
- end;
- end ELSE begin
- if tab[x]<tab[x+1] then begin
- ify1:=ify1+1;
- schowek:=tab[x+1];tab[x+1]:=tab[x];tab[x]:=schowek;
- end;
- end;
- end;
- gotoxy(5,y+5); for t:=1 to 10 do begin write(tab[t]);end;writeln;
- end;
- end;
- procedure sortuj2;
- var
- max,a,schowek,i,t,poz: integer;
- begin
- i:=1;
- poz:=1;
- REPEAT
- max:=tabd[i];
- poz:=i;
- for a:=i to 10 do begin
- petle2:=petle2+1;
- if typLosowania=1 then begin
- if tabd[a]<max then begin
- ify2:=ify2+1;
- max:=tabd[a];
- poz:=a;
- schowek:=tabd[poz];
- tabd[poz]:=tabd[i];
- tabd[i]:=schowek;
- end;
- end ELSE begin
- if tabd[a]>max then begin
- ify2:=ify2+1;
- max:=tabd[a];
- poz:=a;
- schowek:=tabd[poz];
- tabd[poz]:=tabd[i];
- tabd[i]:=schowek;
- end; end;
- end;
- gotoxy(40,5+i); for t:=1 to 10 do begin write(tabd[t]);end;writeln;
- i:=i+1;
- UNTIL i=10;
- end;
- begin clrscr; typLosowania:=1;
- REPEAT losuj;sortowanieBabelkowe;sortuj2;licznik:=licznik+1;UNTIL licznik=100;
- wyswietl;nizej:=1;writeln;
- writeln;wyswietl;
- readkey;end.
Advertisement
Add Comment
Please, Sign In to add comment