mission3.adb

with Gada.Text_IO ;

procedure Mission3 is

   package Txt renames GAda.Text_IO ;

   -- Définition d'un type représentant un tableau d'entiers.
   type T_Ints is array (Integer range <>) of Integer ;

   -- Procédure qui affiche tous les éléments.
   procedure Afficher (Tab : T_Ints) is
   begin
      Txt.Put_Line("Contenu du tableau : ") ;

      for No in Tab'Range loop
         Txt.Put( Integer'Image(Tab(No)) ) ;

         -- Facultatif : séparer les éléments par des virgules.
         if No < Tab'Last then
            Txt.Put(", ") ;
         else
            -- Fin du tableau, on passe à la ligne.
            Txt.Put_Line(".") ;
         end if ;
      end loop ;

   end Afficher ;

   -- Fonction qui construit un tableau de la taille indiquée
   function Creer (Taille : Integer) return T_Ints is

      -- Important : on fait commencer l'indice à 1
      Resultat : T_Ints(1..Taille) ;
   begin
      for No in Resultat'Range loop
         Resultat(No) := No ;
      end loop ;

      return Resultat ;
   end Creer ;

begin

   Afficher(Creer(5)) ;
   Afficher(Creer(15)) ;

end Mission3 ;