【发布时间】:2021-06-01 20:10:55
【问题描述】:
// take a=4 and b=2;
if(a%b)
cout<<"true";
else
cout<<"false";
程序输出false。我有点困惑,因为if 条件只传递真值,if(a%b) 表示a%b==0;那为什么if语句没有通过呢?
【问题讨论】:
-
以一种详细的方式,这是测试“a 是否不能完全被 b 整除”。至于这是如何工作的,以及 % 指的是答案。
标签: c++ if-statement c++17 c++14 implicit-conversion