with Ada.Text_IO,Ada.Integer_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure Slice is
type MY_ARRAY is array(1..12) of Integer;
First,Second:MY_ARRAY;
Funny:array(1..33)of Integer;
begin
for Index in 1..33 loop
Funny(Index):=100+Index*2;
end loop;
for Index in 1..12 loop
First(Index):=Index;
end loop;
Second(1..5):=First(3..7);
Second(1..4):=First(6..9);
Second(7..12):=First(3..8);
First(2..9):=First(5..12);
First(1..12):=MY_ARRAY(Funny(1..12));
First(1..12):=MY_ARRAY(Funny(16..27));
for Index in 1..12 loop
Put("The array named First has the values");
Put(First(Index));
New_Line;
end loop;
end Slice;
045.数组间的切片(赋值)
最新推荐文章于 2024-12-07 15:47:56 发布
本文展示了一个使用Ada编程语言进行数组操作的例子,包括数组初始化、元素赋值和打印。通过对两个不同大小的整数数组进行片段复制和整体替换,演示了Ada中数组切片和类型转换的用法。
1306

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



