zoukankan      html  css  js  c++  java
  • 计算20140215

    是&&,逻辑与运算
    不是&,位与运算
    楼主,结果是1没错
    7和4都为真,所以最后结果为真,即1
    答案为1。
    详解:
    !(a+b)+c-1 && b+c/2
    等价于
    (!(a+b)+c-1) && (b+c/2)
    计算机内部计算步骤(可以查看汇编)
    先算!(a+b)+c-1 ——>0+5-1——>4
    测试上一步结果(结果为4),表达式为真。
    再算b+c/2——>结果为6(注意4/2结果为2,因为都是整型,余数丢掉)
    测试上一步结果(结果为6),表达式为真。
    最后,将结果1赋给整个表达式,即最后的结果。
    #include <iostream>
    using namespace std;
    int main()
    {
     int a = 3,b = 4,c = 5;
     int result = !(a+b)+c-1 && b+c/2;
     int step1 = !(a+b)+c-1;
     int step2 = b+c/2;
     cout<<"The result is ";
     cout<<result<<endl;
     return 1;
    }
    #include <iostream>
    using namespace std;
    int main()
    {
        int a = 3, b = 4, c = 5, x, y;
        cout << (a + b>c && b == c) << endl;
        cout << (a || b + c && b - c) << endl;
        cout << (!(a>b) && !c || 1) << endl;
        cout << (!(x = a) && (y = b) && 0) << endl;
        cout << (!(a + b) + c - 1 && b + c / 2) << endl;
        system("pause");
        return 0;
    }
    #include <iostream>
    using namespace std;
    int main()
    {
        int a, b, c;
        cout << "please enter three integer numbers:";
        cin >> a >> b >> c;
        if (a<b)
        if (b<c)
            cout << "max=" << c;
        else
            cout << "max=" << b;
        else if (a<c)
            cout << "max=" << c;
        else
            cout << "max=" << a;
        cout << endl;
        system("pause");
        return 0;
    }


  • 相关阅读:
    2.19
    2.16sqlite
    2.14Android6
    2.12Android5
    2.11Android4
    2.09Android3
    2.08Android2
    2.06Android学习
    dpdk bond
    ContainerCreating
  • 原文地址:https://www.cnblogs.com/yuanqi/p/3550580.html
Copyright © 2011-2022 走看看