我正在尝试在 Python 中编写与以下语句等效的 Ada:L = [[] for i in range(n)]
我正在解决一个动态规划问题,我的计划是如果第 i 个数组的元素少于第 j 个数组的元素,则最终将 L 中第 j 个数组的内容复制到第 i 个数组中(j < i)。
我已经找到了如何通过以相反的顺序定义其范围来创建一个空数组。因此,例如, arr2 将是一个如下创建的空数组:
arr2:整数数组(2 .. 1);
我的问题是,如何定义更大的数组 L 以包含 n 个这样的 arr2 数组?
请告诉我。
更新:我能够使用下面的答案使其正常工作。这是我的代码。
package Integer_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Integer);
N: Integer;
Array_Of_Vectors : array(1 .. N) of Integer_Vectors.Vector := (others => Integer_Vectors.Empty_Vector);
Input_Sequence: Integer_Vectors.Vector;
Max: Integer_Vectors.Vector;
Input_List : String := Get_Line;
IntCast : Integer;
Last : Positive := 1;
begin …Run Code Online (Sandbox Code Playgroud)