Program rendezesek; {rendezes.pas: 90.11.07} Uses Crt; Const Meret=100; Ism=100; Type Elem = Integer; Index = 1..Meret; Vektor= Array [Index] of Elem; Var a,b : Vektor; rsz, csdb: LongInt; sz : String; atl : Real; c : Char; Min, Max : LongInt; Procedure Csere(Var x: Vektor; i,j: Index); Var s : Elem; Begin s:=x[i]; x[i]:=x[j]; x[j]:=s; {Inc(csdb);} End; {Csere} Procedure Egyenes; Var i : Index; Begin For i:=1 to Meret do a[i]:=i; End; {Egyenes} Procedure Forditott; Var i : Index; Begin For i:=1 to Meret do a[i]:=Meret-i; End; {Forditott} Procedure RND_Permutal(Var x : Vektor); Var i,j,k : Index; Begin For i:=1 to Meret do Begin j:=Random(Meret)+1; Csere(x,j,i); End; For i:=1 to Meret do Begin j:=Random(Meret)+1; k:=Random(Meret)+1; Csere(x,j,k); End; End; {RND_Permutal} Procedure Rendez(Var x : Vektor); Var i,j : Index; mini: Index; min : Elem; Begin csdb:=0; For i:=1 to Meret-1 do Begin mini:=i; min:=x[i]; Inc(csdb); For j:=i+1 to Meret do Begin If x[j]',csdb); LowVideo; Readln; Min:=csdb; End else if csdb>Max then Begin HighVideo; Write('Maximum:',Max,'=>',csdb); LowVideo; Readln; Max:=csdb; End {End If}; atl:=((rsz-1)*atl+csdb)/rsz; Writeln(' Atlag:',atl:6:2); Writeln(' Elmeleti minimum:',Min:5); Writeln(' - " - maximum:',Max:5); Sound(1720); Delay(50); While Keypressed do Begin Delay(200); For i:=1 to Meret do Write(x[i]:4); Readln; End; NoSound; End; {EredmenyKiiras} Begin Delay(1000); Randomize; Min:=3*Meret-3; Max:=3*Meret-3+Meret*Meret div 4; atl:=0; rsz:=1; {Rendezesszam} Egyenes; b:=a; Rendez(b); EredmenyKiiras('Egyenes',a); Forditott; b:=a; Rendez(b); EredmenyKiiras('Forditott',a); For rsz:=3 to Ism+2 do Begin Str(rsz-2:2,sz); RND_Permutal(b); a:=b; Rendez(b); EredmenyKiiras('Random '+sz,a); End; c:=ReadKey End.