#include
int main()
{
/*__________________算术运算符___________________*/
//1、加/减法运算
int a =10;
int b =20 + a; //30
b = a - (20 -10); //0
//2、乘法运算
int c =10 * a;
//除法运算
//整数与整数运算依然是整数
double d =10/4;//2.0
// double d1 = (double)10/4;
double d1 =10/(double)4;
//注意;这样不行
// double d1 = (double)(10/4);
double d2 =10.0/4;
printf("d1:%.1f d2:%.2f\n",d1,d2);
//3.模运算(取余运算)
//两侧都是整数
// int m1 = 5.0%2;//错误,不能为非整数
int m1 =5 % 2;//1
int m2 =2 % 5;//2
int m3 = -5 %2;//结果的正负和第一个数有关
printf("m1:%d m2:%d m3:%d\n",m1,m2,m3);
//4、扩展运算符 ‘=’是赋值运算
int f1 =100;
// f1 += 30;//等价于:f1 = f1+30;
f1 *= 2;//等价于:f1 = f1*2;
//5.自增、自减运算
int z1 =20;
// z1--;//z1 = z1-1;
--z1;
printf("%d\n", z1);
++z1;
// z1 ++;
printf("%d\n", z1);
// 10 ++;//10 = 10 + 1; 错误,只能适用于变量
//a++和++a的区别
int z2 =10;
int result = z2 ++;//先将z2交给result,再加一
printf("result:%d\n", result);
printf("z2:%d\n", z2);
int z3 =10;
result = ++ z3;//先加一,再将z2交给result
printf("result:%d\n", result);
printf("z3:%d\n", z3);
return0;
}