我是艾达的新手。我正在尝试使以下代码工作:
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/