unit melanger; interface uses sysutils, dialogs; type Tablo = array[0..99] of byte; Function Plin(nbr : byte):Boolean; Function MelangerF:Tablo; Function ReMelanger(Sac:Tablo; SacPos : byte):tablo; implementation uses Main; var CurAlphabet : array[1..26] OF byte; Const MaxAlphabet: array[1..26] OF Byte = (9,2,2,3,15,2,2,2,8,1,1,5,3,6,6,2,1, 6,6,6,6,2,1,1,1,1); Function Plin(nbr : byte):Boolean; Begin Inc(CurAlphabet[nbr]); IF CurAlphabet[nbr] <= MaxAlphabet[Nbr] Then Result := true Else Result := False; End; Function MelangerF:Tablo; var a, b, c : Tablo; I,j, d,XX : byte; bol : boolean; begin For i := 1 to 26 Do CurAlphabet[I] := 0; Randomize; A[0] := Random(26) + 1; Plin(A[0]); For I := 1 To 99 Do Begin Repeat A[i] := Random(26)+ 1; Until Plin(A[I]); End; XX := 0; Repeat inc(XX); b[0] := Random(100); For I := 1 to 99 do Begin Repeat Bol := true; B[I] := Random(100); For J := 0 To I - 1 DO Begin IF B[I] = B[J] Then Begin bol := false; break; end; end; until bol; end; For I := 0 to 99 Do C[I] := A[B[I]]; A[0] := Random(100); For I := 1 to 99 Do Begin Repeat Bol := true; A[I] := Random(100); For J := 0 To I - 1 DO Begin IF A[I] = A[J] Then Begin bol := false; break; end; end; until bol; end; For I := 0 to 99 Do B[I] := C[A[I]]; C[0] := Random(100); For I := 1 to 99 Do Repeat Bol := true; C[I] := Random(100); For J := 0 To I - 1 DO Begin IF C[I] = C[J] Then Begin bol := false; break; end; end; until bol; For I := 0 to 99 Do A[I] := B[C[I]]; until XX = 100; Result := A end; Function ReMelanger(Sac:Tablo; SacPos : byte):tablo; var a, b, c : Tablo; I,j, d,XX : byte; bol : boolean; Begin A := Sac; B := Sac; C := Sac; XX := 0; Repeat inc(XX); b[SacPos] := Random(99 - SacPos + 1); For I := SacPos + 1 to 99 do Begin Repeat Bol := true; B[I] := Random(99 - SacPos + 1); For J := SacPos To I - 1 Do Begin IF B[I] = B[J] Then Begin bol := false; end; end; until bol; end; For I := SacPos to 99 Do C[I] := A[B[I] + SacPos]; A[SacPos] := Random(99 - SacPos + 1); For I := SacPos + 1 to 99 Do Begin Repeat Bol := true; A[I] := Random(99 - SacPos + 1); For J := SacPos To I - 1 DO Begin IF A[I] = A[J] Then Begin bol := false; break; end; end; until bol; end; For I := SacPos to 99 Do B[I] := C[A[I]+ SacPos]; C[SacPos] := Random(99 - SacPos + 1); For I := SacPos + 1 to 99 Do Repeat Bol := true; C[I] := Random(99 - SacPos + 1); For J := SacPos To I - 1 DO Begin IF C[I] = C[J] Then Begin bol := false; break; end; end; until bol; For I := SacPos to 99 Do A[I] := B[C[I] + SacPos]; until XX = 1; Result := A; End; end.