c++ cdi+示例

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

“ not”是一个内置关键字,至少从C ++ 98起就存在。 它是替代! ( 逻辑非 )运算符,它通常与条件一起使用。

The not keyword returns 1 if the result of the given condition is 0, and it returns 0 if the result of the given condition is 1.

如果给定条件的结果为0,则not关键字返回1;如果给定条件的结果为1,则not返回0。

Syntax:

句法:

    not operand;

Here, operand is the operand.

在此, 操作数是操作数。

Example:

例:

    Input:
    a = 10;
    b = 20;
    
    result = not(a < b);

    Output:
    result = 1

C ++示例演示“ not”关键字的用法 (C++ example to demonstrate the use of "not" keyword)

// C++ example to demonstrate the use of 
// 'not' operator.

#include <iostream>
using namespace std;

int main()
{
    int num = 20;

    if (not(num >= 10 and num <= 50))
        cout << "true\n";
    else
        cout << "false\n";

    if (not(num >= 20 and num <= 50))
        cout << "true\n";
    else
        cout << "false\n";

    if (not(num > 50 and num <= 100))
        cout << "true\n";
    else
        cout << "false\n";

    return 0;
}

Output:

输出:

false
false
true


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

c++ cdi+示例

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐