我写了一个程序,但是有一个我不能理解的错误。
错误: main.pas(23,11)致命:语法错误,应为")“,但找到”序数常量“
program Hello; <-- 10 line
var
x : integer;
y : integer;
begin
for x := 0 to 120 do
begin
<-- error line
if ( x % 5 = 0 ) then
writeln (x);
end;
end. <-- 30 line
发布于 2020-11-26 21:26:49
x % 5 = 0
是错误所在。
您可能想要使用模运算符。
%
是c和其他语言中的模运算符。在PASCAL语言中,模运算符是mod
。
正确的说法应该是:
if (x mod 5 = 0) then WriteLn(x);
https://stackoverflow.com/questions/65021341
复制相似问题