with Ada.Text_IO,Ada.Integer_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure ArrayOp2 is
type ARY_INT is array(1..6) of Integer;
Crowd,Group1,Group2:ARY_INT;
function "+" (In_Array1,In_Array2:ARY_INT)return ARY_INT is
Temp_Array:ARY_INT;
begin
for Index in ARY_INT'Range loop
Temp_Array(Index):=In_Array1(Index)+In_Array2(Index);
end loop;
return Temp_Array;
end "+";
function "mod"(In_Array1,In_Array2:ARY_INT)return ARY_INT is
Temp_Array:ARY_INT;
begin
for Index in ARY_INT'Range loop
Temp_Array(Index):=In_Array1(Index) mod In_Array2(Index);
end loop;
return Temp_Array;
end "mod";
begin
Group1:=(12,17,-1,3,-100,5);
Group2:=(13,-2,22,1,1242,-12);
Crowd:=Group1+Group2;
for Index in ARY_INT'RANGE loop
Put(Group1(Index), 6);
Put(Group2(Index), 6);
Put(Crowd(Index), 6);
New_Line;
end loop;
end ArrayOp2;
095.重载加法运算符用于两个数组的相加
最新推荐文章于 2022-11-19 11:37:20 发布