1. 运算符分类

  • 算术运算符            【+, -,*, /, % , ++, --】
  • 关系运算符             【>,  >=, <, <=】
  • 相等性运算符           [==,  != ]
  • 逻辑运算符             【&&, ||】(&& 高于 ||)
  • 赋值运算符             【 = 】
  • 按位运算符             【&, |, ^】

2. 优先级与结合律

  ( ), [ ], ->, .                                                                从左至右

 !, ~, ++, --, +, -, *, & (type) sizeof()    从右至左

 *, /, %                                                                        从左至右

 +, -                                                                           从左至右

 <<, >>                                                                          从左至右

 <, <=, >, >=                                                                  从左至右

 ==, !=                                                                       从左至右

 &                                                                                   从左至右

 ^                                                                                    从左至右

 |                                                                               从左至右

 &&                                                                           从左至右

 ||                                                                                   从左至右

 ?:                                                                                 从右至左

 =, +=, -=, /=, %=, &=                                              从右至左

 ^=, !=, <<=,  >>=                                                          从左至右

 ,

05-22 05:21