From: juanmiuk <juanmiuk@googlemail.com>
Subject: Re: I need feedback
Date: Wed, 15 Jun 2011 21:24:21 -0700 (PDT)
Date: 2011-06-15T21:24:21-07:00 [thread overview]
Message-ID: <7249477f-1b33-4546-b1cd-f7333e2cff00@y30g2000yqb.googlegroups.com> (raw)
In-Reply-To: 04cf1b2d-5ae4-4219-9d4c-20231ca47375@k16g2000yqm.googlegroups.com
Well, Thank you for all suggestion, I think I follow all of them.
There you go the final version:
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Fixed;
use Ada;
use Ada.Strings.Fixed;
procedure Sort_3_Numbers is
subtype One_Ten is Integer range 1 .. 10;
package Roulette10 is new Ada.Numerics.Discrete_Random(One_Ten);
Gen10: Roulette10.Generator;
WIDTH_NUM : constant One_Ten := One_Ten'Width;
THE_BASE : constant One_Ten := 10;
procedure Output_Num
( The_Number : in One_Ten;
Width_Num : in One_Ten;
The_Base : in One_Ten )
is
begin
Integer_Text_IO.Put(The_Number, Width_Num, The_Base);
end Output_Num;
begin
Roulette10.Reset(Gen10);
for I in One_Ten'Range loop
Main_Process : declare
A : One_Ten := Roulette10.Random(Gen10);
B : One_Ten := Roulette10.Random(Gen10);
C : One_Ten := Roulette10.Random(Gen10);
First : One_Ten;
Secon : One_Ten;
Third : One_Ten;
begin
Output_Num(A, WIDTH_NUM, THE_BASE);
-- Changing all the Output_Num by Integer_Text_IO.Put(A,
WIDTH_NUM, THE_BASE)
-- as Jeffrey Carter comments then won't be any
dupplications.
Text_IO.Put(", ");
Output_Num(B, WIDTH_NUM, THE_BASE);
Text_IO.Put(", ");
Output_Num(C, WIDTH_NUM, THE_BASE);
Text_IO.Put(" --");
if (A >= B) then
if (A >= C) then
First := A;
if (B >= C) then
-- First := A;
Secon := B;
Third := C;
else
-- First := A;
Secon := C;
Third := B;
end if;
else -- C > A >= B
First := C;
Secon := A;
Third := B;
end if;
elsif (B >= A) then
if (B >= C) then
First := B;
if (A >= C) then
-- First := B;
Secon := A;
Third := C;
else
-- First := B;
Secon := C;
Third := A;
end if;
else -- C > B >= A
First := C;
Secon := B;
Third := A;
end if;
end if;
Output_Num (First, WIDTH_NUM, THE_BASE);
Text_IO.Put(", ");
Output_Num (Secon, WIDTH_NUM, THE_BASE);
Text_IO.Put(", ");
Output_Num (Third, One_Ten'Width, 10);
Text_IO.New_Line;
end Main_Process;
end loop;
end Sort_3_Numbers;
next prev parent reply other threads:[~2011-06-16 4:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-14 21:12 I need feedback juanmiuk
2011-06-14 21:50 ` Ludovic Brenta
2011-06-15 9:10 ` Pascal Obry
2011-06-15 11:40 ` Yannick Duchêne (Hibou57)
2011-06-15 19:38 ` Shark8
2011-06-16 4:24 ` juanmiuk [this message]
2011-06-16 7:34 ` Ludovic Brenta
2011-06-14 23:16 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox