【发布时间】:2015-05-20 19:18:10
【问题描述】:
#include<iostream>
int main()
{
int count = 1;
while (count <= 5)
{
cout<<(count % 2 ? "****" : "++++++++")<< endl;
++count;
}
system ("pause");
return 0;
}
我无法理解count%2,条件不应该是count%2==0吗?如果是count%2,编译器怎么知道是真是假?
【问题讨论】:
-
阅读有关 C++ 的介绍性书籍或教程。说真的。
标签: c++ ternary-operator