comp.lang.ada
 help / color / mirror / Atom feed
* I need feedback
@ 2011-06-14 21:12 juanmiuk
  2011-06-14 21:50 ` Ludovic Brenta
  2011-06-14 23:16 ` Jeffrey Carter
  0 siblings, 2 replies; 8+ messages in thread
From: juanmiuk @ 2011-06-14 21:12 UTC (permalink / raw)


My name is Juan Miguel and I have ADHD. Since I have long wanted to
learn Ada but I could not learn, because the medication was not
correct and I could not concentrate properly. I returned to writing
simple programs to get base. All I want is to tell me how I am doing.
Thanks in advance.


with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Fixed;

use Ada;
use Ada.Strings.Fixed;

procedure ordenar_3_numeros_better is

	type UnoDiez is range 1 .. 10;

	package Ruleta10 is new Ada.Numerics.Discrete_Random(UnoDiez);

	Gen10: Ruleta10.Generator;

begin

	Ruleta10.Reset(Gen10);
	for I in 1 .. 10 loop

   		Proceso_Principal: declare

			A		: UnoDiez := Ruleta10.Random(Gen10);
			B		: UnoDiez := Ruleta10.Random(Gen10);
			C		: UnoDiez := Ruleta10.Random(Gen10);

			First	: UnoDiez;
			Secon	: UnoDiez;
			Third	: UnoDiez;

   		begin

			Formateo_Salida_1: declare

				Separador1 : String := (UnoDiez'Width - UnoDiez'Image(A)'Length) *
' ';
				Separador2 : String := (UnoDiez'Width - UnoDiez'Image(B)'Length) *
' ';
				Separador3 : String := (UnoDiez'Width - UnoDiez'Image(C)'Length) *
' ';

			begin

				Text_IO.Put (
								Separador1 & UnoDiez'Image(A) & ","    &
								Separador2 & UnoDiez'Image(B) & ","    &
								Separador3 & UnoDiez'Image(C) & "  --"
							);
			end Formateo_Salida_1;

			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;

			Formateo_Salida_2: declare

				Separador1 : String := (UnoDiez'Width -
UnoDiez'Image(First)'Length) * ' ';
				Separador2 : String := (UnoDiez'Width -
UnoDiez'Image(Secon)'Length) * ' ';
				Separador3 : String := (UnoDiez'Width -
UnoDiez'Image(Third)'Length) * ' ';

			begin

				Text_IO.Put (
								Separador1 & UnoDiez'Image(First) & ","  &
								Separador2 & UnoDiez'Image(Secon) & ","  &
								Separador3 & UnoDiez'Image(Third)
							);
				Text_IO.New_Line;
			end Formateo_Salida_2;
      	end Proceso_Principal;
	end loop;
end ordenar_3_numeros_better;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-06-16  7:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-06-16  7:34         ` Ludovic Brenta
2011-06-14 23:16 ` Jeffrey Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox