为什么pascal不能写布尔值

Why pascal can't write boolean value

我有一个代码:

for i:=0 to High(a) do
begin 
    { I want to write 0 and 1 represent for true and false }
    writeln(i % 2 = 0);
end;

但是"writeln"行出现错误

Syntax error, ")" expected but "ordinal const" found

谁能帮帮我? :(

谢谢 :D

在Pascal/Delphi中取模运算符为mod:

writeln(i mod 2 = 0);

% 根本不是 Pascal/Delphi 运算符。

因此,这与 Writeln 过程不接受布尔值无关。


这将打印 FALSETRUE。如果你想要 01,你需要 Ord(i mod 2 = 0) 或者更好的是 Ord(not Odd(i)).