with Ada.Text_IO,Ada.Integer_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure LoopDemo is
Index,Count : Integer;
begin
Index:=1;
loop -- this is simlest loop
Put("Index=");
Put(Index,5);
New_Line;
Index:=Index+1;
exit when Index=5;
end loop;
Index:=1;
loop -- another simplest loop
Put("index=");
Put(Index,5);
New_Line;
Index:=Index+1;
if Index=5
then exit;
end if ;
end loop;
Count:=1;
while Count<5 loop -- this is the while loop
Put("Count=");
Put(Count,5);
New_Line;
Count:=Count+1;
end loop;
for Index in 1..4 loop -- this is the for loop
Put("Doubled index =");
Put(2*Index,5);
New_Line;
end loop;
for Count in reverse 5..8 loop -- this is the reverse for loop
Put("Triple index =");
Put(3*Count,5);
New_Line;
end loop;
for Index in 7..11 loop -- an empty loop
null;
end loop;
end LoopDemo;
014.Ada语言循环程序设计Demo01
最新推荐文章于 2023-05-25 23:18:54 发布