优先级
|
运算符
|
结合律
|
从
高
到
低
排
列
|
( ) [ ] -> .
|
从左至右
|
! ~ ++ -- (类型) sizeof
+ - * &
|
从右至左
|
|
* / %
|
从左至右
|
|
+ -
|
从左至右
|
|
<< >>
|
从左至右
|
|
< <= > >=
|
从左至右
|
|
== !=
|
从左至右
|
|
&
|
从左至右
|
|
^
|
从左至右
|
|
|
|
从左至右
|
|
&&
|
从左至右
|
|
||
|
从右至左
|
|
?:
|
从右至左
|
|
= += -= *= /= %= &= ^=
|= <<= >>=
|
从左至右
|
for (row=0; row<100; row++)
{
for ( col=0; col<5; col++ )
{
sum = sum + a[row][col];
}
}
|
for (col=0; col<5; col++ )
{
for (row=0; row<100; row++)
{
sum = sum + a[row][col];
}
}
|
for (i=0; i<N; i++)
{
if (condition)
DoSomething();
else
DoOtherthing();
}
|
if (condition)
{
for (i=0; i<N; i++)
DoSomething();
}
else
{
for (i=0; i<N; i++)
DoOtherthing();
}
|
for (int x=0; x<N; x++)
{
…
}
|
for (int x=0; x<=N-1; x++)
{
…
}
|