''Program sortuje litery alfabetu'' program rekordy; uses crt; type cos=record pole1:integer; pole2:char; end; const maxroz=10; var tab:array[1..1000] of cos; i,j,m,pom,n:integer; pom1:char; begin clrscr; write('podaj rozmiar tablicy'); read(n); randomize; for i:=1 to n do begin tab[i].pole1:=random(1000); tab[i].pole2:=chr(65+random(26)); writeln(tab[i].pole1,' ',tab[i].pole2); end; for i:=2 to n do begin j:=i; while(j>1) and (tab[j-1].pole1>tab[j].pole1) do begin pom:=tab[j].pole1; pom1:=tab[j].pole2; tab[j].pole1:=tab[j-1].pole1; tab[j].pole2:=tab[j-1].pole2; tab[j-1].pole1:=pom; tab[j-1].pole2:=pom1; j:=j-1; end; end; for i:=2 to n do begin j:=i; while(j>1) and (tab[j-1].pole2>tab[j].pole2) do begin pom1:=tab[j].pole2; pom:=tab[j].pole1; tab[j].pole2:=tab[j-1].pole2; tab[j].pole1:=tab[j-1].pole1; tab[j-1].pole2:=pom1; tab[j-1].pole1:=pom; j:=j-1; end; end; writeln('uporzadkowana tablica:'); for i:=1 to n do write(tab[i].pole2,'-',tab[i].pole1,' '); readln; readln; end.
This topic: Main
>
Program2
Topic revision:
09 Jun 2004,
DorotaP
(raw view)
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback