All pastes #765159 Raw Edit

loop

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


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


begin
   put ("Groesste Zahl: ");
   get (Groesste_Zahl);
   put (I, 1);

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

      if I = Groesste_Zahl then
         exit;
      end if;
   end loop;

   --

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

      if I = 1 then
         null;
      end if;
   exit;
   end loop;

end Count_Loop;