首页 > 解决方案 > 如何测试一个条件是否为真?

问题描述

如果我在 Pascal 中有一组布尔变量,我如何测试其中一个是否是True

标签: booleanpascal

解决方案


在 Pascal 中,您可以这样做:

if Integer(a) + Integer(b) + Integer(c) = Integer(true) then
    writeln("exactly one is true");

与 进行比较很重要Integer(true),因为它在不同版本的 Pascal 中可能是不同的值。


推荐阅读