std::cout 条件打印
时间: 2023-10-22 13:07:35 浏览: 79
cout不打印,不显示,不输出 怎么办?
5星 · 资源好评率100%
可以使用条件运算符 ?: 来进行条件打印,例如:
```c++
int x = 10;
int y = 20;
std::cout << ((x > y) ? "x is greater than y" : "x is less than or equal to y") << std::endl;
```
输出结果为 "x is less than or equal to y"。
阅读全文