#include <stdio.h> int main(void) { int logic; int a = 1; int b = 2; int c = 3; logic = a + b > c && b <= c; printf("logic = %d ",logic ); //输出0 logic = a >= b + c || b == c; printf("logic = %d ",logic ); //输出0 logic = !(a < c) + b != 1 && (a + c)/2; printf("logic = %d ",logic ); //输出1 /** !(a < c) + b != 1 && (a + c)/2 ==> ((!(a < c) + b) != 1) && (( a + c)/2 ) ==> ((! 1 + b) != 1 ) && (4 / 2) ==> 1 && 2 ==> 1 */ return 0; } /** 除运算符"!"之外,所有关系和逻辑操作符的优先级都低于算术操作符 */
运算符的优先级排序