fix: converted single to triple backticks5 (#36232)
This commit is contained in:
@@ -13,26 +13,28 @@ localeTitle: مشغل شرطي
|
||||
|
||||
هنا ، يتم تقييم expression-1 عندما يكون الشرط صحيحًا ويتم تقييم expression-2 عندما تكون condtion خاطئة. عبارة if-else مشابهة ستكون:
|
||||
|
||||
`if(condition)
|
||||
{
|
||||
expression-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
expression-2;
|
||||
}
|
||||
`
|
||||
```cpp
|
||||
if(condition)
|
||||
{
|
||||
expression-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
expression-2;
|
||||
}
|
||||
```
|
||||
|
||||
ومن ثم فإن العامل الشرطي سهل للغاية عندما تحتاج إلى كتابة عبارة if-else بسيطة. ويمكن أيضا أن تستخدم في # تعريف preprocessor عندما يتم استخدام حالة مماثلة في أماكن متعددة.
|
||||
|
||||
على سبيل المثال ، يمكن استخدام الحد الأقصى لعدد المشغلين الشرطيين على النحو التالي:
|
||||
|
||||
`#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
|
||||
`
|
||||
```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
|
||||
```
|
||||
|
||||
**حظا سعيدا لكم جميعا**
|
||||
|
||||
|
Reference in New Issue
Block a user