jun-csbio / CClass_ZJUT

CClass_ZJUT
1 stars 0 forks source link

【问题】逻辑运算和布尔类型的相关问题 #51

Closed XiaoBaiBZS closed 11 months ago

XiaoBaiBZS commented 11 months ago
#include <stdio.h> 
int main(){ 
    int a=3;
    int b=4;
    int c=5;

    printf("%d\n", (a || b)+(c && b-c));
    printf("%d\n", a || b+(c && b-c));
    printf("%d\n", (a || b)+c && b-c);
    printf("%d\n", a || b+c && b-c);

    return 0; 
}

为什么输出是2 1 1 1,而不是2 2 2 2

jun-csbio commented 11 months ago

运算符的优先级,去复习一下