在Ada中,我们可以使用 record 和 array 类型来创建列矩阵。下面是一个示例程序:
with Ada.Text_IO; use Ada.Text_IO;
procedure Column_Matrix is
   type Two_D_Array is array (Integer range <>, Integer range <>) of Integer;
   -- Define column matrix
   type Column_Matrix is record
      Rows : Integer;
      Col  : Integer;
      Data : array (Integer range <>, Integer range <>) of Integer;
   end record;
   function Create_Column_Matrix (A : Two_D_Array) return Column_Matrix is
      Result : Column_Matrix;
   begin
      Result.Rows := A'Length(2);
      Result.Col  := A'Length(1);
      for i in 1 .. Result.Col loop
         for j in 1 .. Result.Rows loop
            Result.Data (j, i) := A (i, j);
         end loop;
      end loop;
      return Result;
   end Create_Column_Matrix;
   -- Test the function
   A : Two_D_Array (1 .. 5, 1 .. 3) :=
               ((1, 2, 3),
                (4, 5, 6),
                (7, 8, 9),
                (10, 11, 12),
                (13, 14, 15));
   CM : Column_Matrix := Create_Column_Matrix (A);
begin
   -- Print the column matrix
   for i in 1 .. CM.Col loop
      for j in 1 .. CM.Rows loop
         Put (CM.Data (j, i)'Image & " ");
      end loop;
      New_Line;
   end loop;
end Column_Matrix;
在上面的代码中,我们首先声明了一个用于存储二维整数数组的类型 Two_D_Array。接着,我们定义了一个定义列矩阵的 record 类型,包括行、列和数据数组。然后,我们实现了一个名为 Create_Column_Matrix 的函数,用于将二维数组转换为列矩阵。最后,我们通过对 Create_Column_Matrix 函数的调用测试了它的效