All pastes #765300 Raw Edit

loop

public text v1 · immutable
·published 2007-11-07 22:38 UTC
rendered paste body
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;


procedure Count_Loop2 is 
   I : Integer := 1;
   Groesste_Zahl : Integer;


begin
   Put ("Groesste Zahl: ");
   Get (Groesste_Zahl);
   if Groesste_Zahl > 0 then
   New_Line;
   Put (I, 1);
   Put (", ");
   --
   loop
      if I < Groesste_Zahl then
         I := I + 1;
         Put (I, 1);
      end if;

         if I >= Groesste_Zahl then
            exit;
            else
            Put (", ");
         end if;      

   end loop;
   New_Line;

   --

   Put (Groesste_Zahl, 1);
   Put (", ");
   loop
      if I <= Groesste_Zahl then
         I := I - 1;
         Put (I, 1);
         if I = 1 then
               exit;
            else
               Put (", ");
               I := I - 1;
               Put (I, 1);
               Put (", ");
         end if;
      end if;

   end loop;

   end if;

end Count_Loop2;