尝试编译“直到”预期发现“其他”时发生致命错误,似乎无法解决问题
...
begin
divisor:= 2;
cont:= 0;
write(i,':');
repeat
if (i mod divisor = 0) then
begin
write(' divisor ');
divisor:=succ(divisor);
cont:=succ(cont);
end;
else
divisor:=succ(divisor);
until (cont = 6) or (divisor>i div 2)
writeln();
end;
end;
end.
答案 0 :(得分:5)
问题是您在end;
之前else
之后有分号。这基本上会终止if
语句,因此else
变为else
到repeat
(显然无效)。解决方法是在end;
请参阅此参考:http://wiki.freepascal.org/Else
修正:
if (i mod divisor = 0) then
begin
write(' divisor ');
cont:=succ(cont);
end
else
divisor:=succ(divisor);