gpt4 book ai didi

Ada:循环导致后面的代码无法访问

转载 作者:行者123 更新时间:2023-12-04 21:22:23 25 4
gpt4 key购买 nike

我是艾达的新手。我正在尝试使以下代码工作:

begin
Ada.Text_IO.Put_Line("Student ID Score");
Ada.Text_IO.Put_Line("===================");
readAnswers(pAnswers, 1);

loop
declare
counter : Integer := 0;
studentInput : String := Get_Line(Input);
studentScore : Integer;
begin
numOfTests := numOfTests + 1;
current_student.ID := GetID(studentInput);
Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(current_student.ID));
readAnswers(studentInput (6 .. studentInput'Last) ,0);
studentScore := scoreTest(current_student.student_answer, current_answer_key, number_of_questions);
Ada.Integer_Text_IO.Put(studentScore);
New_Line(1);
end;
end loop;

Ada.Text_IO.Put_Line("===================");
Ada.Text_IO.Put("Tests Graded = ");
Ada.Integer_Text_IO.Put(numOfTests);
end;

不幸的是,GNAT 告诉我循环之后的所有代码都无法访问。我怎样才能让这个程序执行循环和它之后的代码?

最佳答案

你忘记了退出条件:

loop
exit when condition;
end loop;

关于Ada:循环导致后面的代码无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59232836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com