All pastes #332878 Raw Edit

test

public text v1 · immutable
#332878 ·published 2007-01-30 10:30 UTC
rendered paste body
------------------------|
--->  Staffan Holmgren  |
--    870702-1716       |
--    D1b               |
--    Grp 2             |
------------------------|

with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_text_Io; use Ada.Integer_Text_Io;
with Ada.Numerics.Discrete_Random;

procedure Labb3 is
   Type My_Array is array(1..20) of Integer;

   procedure Swap (T1, T2 : in out Integer) is
      Temp : Integer;
   begin
      Temp := T1;
      T1 := T2;
      T2 := Temp;
   end Swap;

   --procedure Sort (outArray : in out My_Array) is

   -- begin
   --  for N in OutArray'range loop
   --   for I in reverse OutArray'range loop
   --    if outArray(N) > outArray(I) then
   --      Swap(OutArray (N), OutArray(I));
   --  end if;
   --end loop;
   --end loop;
   --end Sort;
------------------------|
--->  Staffan Holmgren  |
--    870702-1716       |
--    D1b               |
--    Grp 2             |
------------------------|

with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_text_Io; use Ada.Integer_Text_Io;
with Ada.Numerics.Discrete_Random;

procedure Labb3 is
   Type My_Array is array(1..20) of Integer;

   procedure Swap (T1, T2 : in out Integer) is
      Temp : Integer;
   begin
      Temp := T1;
      T1 := T2;
      T2 := Temp;
   end Swap;

   --procedure Sort (outArray : in out My_Array) is

   -- begin
   --  for N in OutArray'range loop
   --   for I in reverse OutArray'range loop
   --    if outArray(N) > outArray(I) then
   --      Swap(OutArray (N), OutArray(I));
   --  end if;
   --end loop;
   --end loop;
   --end Sort;


   --
  
   --

   procedure Generate (outArray : out My_Array) is
      subtype One_To_Ten is Integer range 1 .. 10;
      package One_To_Ten_Random is
         new Ada.Numerics.Discrete_Random(Result_Subtype => One_To_Ten);
      G : One_To_Ten_Random.Generator;
   begin
      One_To_Ten_Random.Reset(G);
      for I in 1 .. 20 loop
         outArray(I) := One_To_Ten_Random.Random(G);
      end loop;
   end Generate;

   OutArray : My_array;
   X : Integer;
begin
   Generate (OutArray);
   sort (OutArray);
   for I in 1..20 loop
      Put (outArray (I));
      New_Line;
   end loop;
Get (x);
end Labb3;

--------------------------------------------------------------------