0
我无法找到我一直在学校编码中遇到的这个错误的来源。每当我在数组中输入一个值并且运行for循环时,它会遇到运行时错误,或者程序的其余部分根据第一个值的信息运行,并且不接受任何其他值。有人可以向我解释如何解决这个问题吗?pascal中未知的运行时错误
program Montserrat_Elections;
Var cndnme : array [1..4] of String;
votes : array [1..4] of Integer;
highest, cnt : Integer;
winner : string;
begin
highest:= 0;
winner:= 'Dan';
For cnt:= 1 to 4 do
begin
Writeln('Please enter the first name of the candidate and the number of votes');
Read (cndnme[cnt], votes[cnt]);
If votes[cnt] > highest then
highest := votes[cnt];
winner := cndnme[cnt];
end;
Writeln('The winner of this constituency is', winner, 'with', highest, 'votes')
end.
阅读关于单独的语句和复合语句。你需要围绕你的身体开始/结束。 –
你不能在一个READ命令中读取一个字符串和一个整数,因为从一个整数中分隔字符串的分隔符是什么?读取空间也是允许的(something_string) –
@David:问题是'Read'语句;它与'if'无关。 –