1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
Button2: TButton;
ListBox3: TListBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var N : integer;
V : array[1..100] of integer;
begin
ListBox1.Clear;
ZeroMemory(@V, SizeOf(V));
for N := 0 to 999999 do
// inc(V[1 + random(20) + random(21) + random(21) + random(21) + random(21)]);
// inc(V[1 + random(50) + random(51)]);
inc(V[1 + random(34) + random(34) + random(34)]);
for N := 1 to 100 do
ListBox1.Items.Add(format('%3.d : %6.2f%% : %6.d',[N, V[N]/10000, V[N]]));
end;
procedure TForm3.Button2Click(Sender: TObject);
var N : integer;
V : array[2..20] of integer;
begin
ListBox2.Clear;
ZeroMemory(@V, SizeOf(V));
for N := 0 to 999999 do
inc(V[ 2 + random(10) + random(10) ]);
for N := 2 to 20 do
ListBox2.Items.Add(format('%3.d : %6.2f%% : %6.d',[N, V[N]/10000, V[N]]));
end;
procedure TForm3.Button3Click(Sender: TObject);
var N : integer;
V : array[1..10] of integer;
begin
ListBox3.Clear;
ZeroMemory(@V, SizeOf(V));
for N := 0 to 999999 do
//inc(V[ 1 + random(10) ]);
inc(V[ 1 + random(4) + random(4) + random(4) ]);
for N := 1 to 10 do
ListBox3.Items.Add(format('%3.d : %6.2f%% : %6.d',[N, V[N]/10000, V[N]]));
end;
initialization
Randomize;
end. |