1、优先级最高:()
2、单目运算符:(如‘!’‘++’‘’)> 双目(如‘+’‘ ’)
3、逻辑运算符:&& > ||
4、赋值运算符最后运行,如‘=’‘>=''<='
示例
int a = 4, b = 5, c = 6;
int res = a + b * c;
printf("%d\n", res);
运行结果
int x = 6;
int res = -x + 4;
printf("%d\n", res);
结果
int a = 5;
int res = a++ * 4;
printf("%d\n", res);
结果
int a = 3, b = 5;
int res = a > b && a < b;
printf("%d\n", res);
结果
int x = 12;
x += x * 2;
printf("%d\n", x);
结果
int a = 7, b = 8, c = 9;
int res = (a + c) * (b - a);
printf("%d\n", res);
结果
#include <stdio.h>
int main() {
int year;
printf("请输入一个年份:");
scanf("%d", &year);
(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ?
printf("%d 年是闰年哈哈哈\n", year) : printf("%d 年不是闰年呜呜呜\n", year);
return 0;
}