fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,44 @@
---
title: Conditional Operator
localeTitle: 条件运算符
---
## 条件运算符
条件运算符是三元运算符它需要3个操作数。 它根据表达式的结果返回两个值中的一个 条件运算符用于替换简单的if-else语句。
句法
```cpp
(condition)?(expression-1):(expression-2);
```
这里,当条件为真时评估表达式-1当条件为假时评估表达式-2。 类似的if-else语句将是
```cpp
if(condition)
{
expression-1;
}
else
{
expression-2;
}
```
因此当您需要编写简单的if-else语句时条件运算符非常方便。它也可以在#define中使用 当在多个地方使用类似条件时的预处理器。
例如,要查找最多两个数字条件运算符,可以使用如下:
```cpp
#define big(a,b) (a>=b)?a:b
int maximum,x=5,y=6; // variable to store maximum of two numbers
maximum=(x>y)?x:y; // directly using conditional operator
maximum=big(x,y); // using the #define preprocessor defined above as big
```
**祝大家好运**
**快乐的编码! :)**
**随意在FreeCodeCamp的GitHub页面或[FreeCodeCamp的论坛](https://forum.freecodecamp.org/)上询问任何问题[](https://forum.freecodecamp.org/)**