日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c++ cdi+示例_C ++“和”关键字示例

發布時間:2023/12/1 c/c++ 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c++ cdi+示例_C ++“和”关键字示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

c++ cdi+示例

"and" is an inbuilt keyword that has been around since at least C++98. It is an alternative to && (Logical AND) operator and it mostly uses with the conditions.

“ and”是一個內置關鍵字,至少從C ++ 98起就存在。 它是&& ( 邏輯AND )運算符的替代方法,它通常與條件一起使用。

The and keyword returns 1 if the result of all operands is 1, and it returns 0 if the result of any condition is 0.

如果所有操作數的結果均為1,則and關鍵字將返回1,如果任何條件的結果為0,則它??將返回0。

Syntax:

句法:

operand_1 and operand_2;

Here, operand_1 and operand_2 are the operands.

在這里,操作數_1和操作數_2是操作數。

Example:

例:

Input:a = 10;b = 20;result = (a==10 and b==20);Output:result = 1

演示使用“ and”關鍵字的C ++示例 (C++ example to demonstrate the use of "and" keyword)

Example 1:

范例1:

// C++ example to demonstrate the use of // 'and' operator.#include <iostream> using namespace std;int main() {int num = 20;if (num >= 10 and num <= 50)cout << "true\n";elsecout << "false\n";if (num >= 20 and num <= 50)cout << "true\n";elsecout << "false\n";if (num > 50 and num <= 100)cout << "true\n";elsecout << "false\n";return 0; }

Output:

輸出:

true true false

Example 2:

范例2:

// Input name, age, height and weight // check you are eligible for the // army selection or not?#include <iostream> using namespace std;int main() {string name;int age;float height, weight;cout << "Enter name: ";cin >> name;cout << "Enter age: ";cin >> age;cout << "Enter height (in cm): ";cin >> height;cout << "Enter weight (in kg): ";cin >> weight;if (age >= 18 and height >= 165 and weight >= 55)cout << name << " , you're selected.";elsecout << name << " , you're not selected.";return 0; }

Output:

輸出:

RUN 1: Enter name: Shivang Enter age: 23 Enter height (in cm): 172 Enter weight (in kg): 67 Shivang , you're selected.RUN 2: Enter name: Akash Enter age: 19 Enter height (in cm): 157 Enter weight (in kg): 70 Akash , you're not selected.

翻譯自: https://www.includehelp.com/cpp-tutorial/and-keyword-with-example.aspx

c++ cdi+示例

總結

以上是生活随笔為你收集整理的c++ cdi+示例_C ++“和”关键字示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。