跳到主要内容

3,运算符

3.1算术运算符

两个小数不允许取余运算

//前置递增
int a = 10;
++a;
count<<"a="<<a<<endl;
//后置递增
int b = 10;
b++;
cout<<"b="<<b<<endl;
//前置和后置的区别
//前置递增,先让变量+1,然后进行表达式运算
int a2 = 10;
int b2 = ++a2*10
cout<<"a2="<<a2<<endl;
cout<<"b2+"<<b2<<endl;
//后置递增,先进行表达式运算,后让变量+1
int a3 = 10;
int b3 = ++a2*10
cout<<"a3="<<a3<<endl;
cout<<"b3+"<<b3<<endl;

3.2赋值运算符

3.3比较运算符

3.4逻辑运算符

Untitled

参考与致谢