From: montgrimpulo <aghte@hotlinemail.com>
Subject: Lotto simulation 2
Date: Mon, 16 Jun 2014 01:03:43 -0700 (PDT)
Date: 2014-06-16T01:03:43-07:00 [thread overview]
Message-ID: <7b5472cb-54c1-4bc4-b89b-8c72e4b72c7d@googlegroups.com> (raw)
Hi,
I want to thank all contributors to my first post on Lotto simulation for their valuable input.
As a conclusion I decided to use the containers.vectors package. Here is my solution. Please
feel free to comment on any aspect.
with Ada.Numerics.Discrete_Random, Ada.Text_IO, Ada.Containers.Vectors;
use Ada.Containers;
procedure Ziehung is
package IO renames Ada.Text_IO;
package ball_container is new Vectors (Positive, Positive);
balls, iball : ball_container.Vector;
tz, iz : Integer;
begin
balls.Set_Length (Length => 49);
iball.Set_Length (Length => 6);
for i in 1 .. 49 loop
balls.Replace_Element (Index => i, New_Item => i);
end loop;
tz := 49;
for i in 1 .. 6 loop
lottoblock : declare
subtype z is Positive range 1 .. tz;
package lb is new Ada.Numerics.Discrete_Random (z);
glb : lb.Generator;
begin
lb.Reset (glb);
iz := lb.Random (glb);
end lottoblock;
iball.Replace_Element
(Index => i, New_Item => balls.Element (Index => iz));
balls.Delete (Index => iz, Count => 1);
tz := tz - 1;
end loop;
IO.Put_Line ("Length_b:" & balls.Length'Img);
IO.Put_Line ("Length_ib:" & iball.Length'Img);
end Ziehung;
Length_b: 43
Length_ib: 6
[2014-06-16] process terminated successfully, elapsed time: 00.21s
next reply other threads:[~2014-06-16 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 8:03 montgrimpulo [this message]
2014-06-16 12:21 ` Lotto simulation 2 Stefan.Lucks
2014-06-16 20:59 ` john
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox