No. | 运算符 | 范例 | 执行前 | 说明 | 执行后 |
a | b | a | b |
1 | += | a += b | 12 | 3 | a + b的值存放到a中(同a = a + b) | 15 | 3 |
2 | -= | a -= b | 12 | 3 | a - b的值存放到a中(同a = a – b) | 9 | 3 |
3 | *= | a *= b | 12 | 3 | a * b的值存放到a中(同a = a * b) | 36 | 3 |
4 | /= | a /= b | 12 | 3 | a / b的值存放到a中(同a = a / b) | 4 | 3 |
5 | %= | a %= b | 12 | 3 | a % b 的值存放到a中(同a = a % b) | 0 | 3 |
6 | b++ | a *= b++ | 12 | 3 | a * b的值存放到a后,b加1(同a = a * b;b++) | 36 | 4 |
7 | ++b | a *= ++b | 12 | 3 | b加1后,再将a*b的值存放到a(同b++;a=a*b) | 48 | 4 |
8 | b-- | a *= b-- | 12 | 3 | a * b的值存放到a后,b减1(同a=a*b;b--) | 36 | 2 |
9 | --b | a *= --b | 12 | 3 | b减1 后,再将a*b的值存放到a(同b--;a=a*b) | 24 | 2 |