小编Mik*_*les的帖子

Ada - 你如何从一行输入中读取数组?

我的问题非常简单,我的输入看起来像这样......

0   0   0   1   1   1  -1  -1  -1   1
Run Code Online (Sandbox Code Playgroud)

我需要将这些值存储到数组中,但我无法弄明白.这就是我到目前为止......

with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
    type arr is array(1..10) of Integer;
    Data : arr;
begin
    for I in 1..arr'Length loop
        Data(I) := Integer'Value(Get_Line);
    end loop;
end Main;
Run Code Online (Sandbox Code Playgroud)

我知道这是错的,很明显为什么这不起作用.我试图将多个值存储到一个整数中,我需要一种迭代输入或一次加载所有值的方法.你会怎么在阿达做这个?

ada

1
推荐指数
1
解决办法
260
查看次数

标签 统计

ada ×1