with Ada.Text_IO,Ada.Integer_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure MoreLoop is
type MY_TYPE is range 10..13;
package My_Int_IO is new Ada.Text_IO.Integer_IO(MY_TYPE);
use My_Int_IO;
My_Range :MY_TYPE;
TWO :constant Integer :=2;
THREE :constant Integer :=3;
FOUR :constant Integer :=4;
Height,Width :Integer;
Special_Index:Integer;
begin
for Index in MY_TYPE loop
Put("Going through the first loop");
Put(Index,3);
New_Line;
end loop;
for Index in MY_TYPE'First..MY_TYPE'Last loop
Put("Going through the second loop");
Put(Index,3);
New_Line;
end loop;
for Index in TWO..THREE**2-FOUR loop -- range is 2..5
Put("Going through the third loop");
Put(Index,3);
New_Line;
end loop;
Named_Loop:
for Height in TWO..FOUR loop
for Width in THREE..5 loop
if Height*Width=12 then
exit Named_Loop;
end if ;
Put("Now we are in the nested loopand area is");
Put(Height*Width,5);
New_Line;
end loop;
end loop Named_Loop;
Special_Index :=157;
for Special_Index in 3..6 loop
Put("In the Special Index loop");
Put(Special_Index,5);
New_Line;
end loop;
Put("The special index loop is completed");
Put(Special_Index,5);
New_Line;
end MoreLoop;
015.Ada语言循环程序设计.Demo02
最新推荐文章于 2020-12-30 15:24:51 发布
76

被折叠的 条评论
为什么被折叠?



