*¡B/¡B%¡B+¡B- ¥H ¤W ©Ò ¼Ð ¥Ü ªº ¹B ºâ ¤l ¡A ¨ä ¹B ºâ
ªº Àu ¥ý ¶¶ §Ç ¥Ñ ¥ª ¦Ü ¥k ¡C
|
t¸¹ (-) |
¬°ªÀu¥ý¶¶§Ç |
|
¼ ( * )¡B°£ ( / )¡B¾l¼Æ( % ) |
¬¤¤Àu¥ý¶¶§Ç |
|
¥[ ( +)¡B´î ( - ) |
¬§CÀu¥ý¶¶§Ç |
»yªk¡G (type)
expression
main( ) { int x1; float y1,y2; x1=(int)4.123; y1=(float)46/5; y2=(int)5.3456; printf("%d %f %f\n",x1,y1,y2); } |
Result:
4 9.20000000 5.00000000 |
»¼ ¼W
»P »¼ ´î ¤S ¤À ¬° «e ¸m ¼Ò ¦¡ ( prefix ) »P «á ¸m ¼Ò ¦¡( postfix ) ¡F
«e ¸m ¼Ò ¦¡¡G¬O ±N ++ ©Î - - ¸m ©ó ÅÜ ¼Æ ¤§ «e¡A¨ä¹Bºâ¬O¦b¨Ï¥Î¦¹¹Bºâ¤¸¤§«e¥ý¶i¦æ¥[¤@©Î´î¤@¤§°Ê§@¡C
«á ¸m ¼Ò ¦¡¡G ¬O ±N ++ ©Î - - ¸m ©ó ÅÜ ¼Æ ¤§ «á¡A¨ä¹Bºâ¬O¦b¨Ï¥Î¦¹¹Bºâ¤¸¤§«á¤~¶i¦æ¥[¤@©Î´î¤@¤§°Ê§@ ¡C
main() { int a=1,b=1,c=1,d=1; int aplus,bplus; int cminus,dminus; aplus=++a; bplus=b++; cminus=--c; dminus=d--; printf("%d %d\n",aplus,bplus); printf("%d %d\n",a,b); printf("%d %d\n",cminus,dminus); printf("%d %d\n",c,d);} |
Result: 2 12 20 10 0 |
¯S®í¹Bºâ¦¡ |
°ò¥»¹Bºâ¦¡ |
a += b |
a = a + b |
a -= b |
a = a - b |
a *= b |
a = a * b |
a /= b |
a = a / b |
a %= b |
a = a % b |
ÅÞ ¿è ¹B ºâ ªº ºØ Ãþ
|
¹Bºâ¤l |
¥\¯à±Ôz |
¹Bºâ¤l |
¥\¯à±Ôz |
|
|
&& |
AND(¤Î) |
~ |
1' complement(¤@ªº¸É¼Æ) |
|
|
|| |
OR(©Î) |
<< |
Left shift(¥ª²¾) |
|
|
! |
NOT(¤Ï¦V) |
>> |
Right shift |
|
|
Ãö «Y ¹B ºâ ¤l |
|
||
|
¹Bºâ¤l |
¥\¯à±Ôz |
¹Bºâ¤l |
¥\¯à±Ôz |
|
< |
¤p©ó
|
>= |
¤j©óµ¥©ó
|
|
<= |
¤p©óµ¥©ó
|
= = |
µ¥©ó
|
|
> |
¤j©ó
|
!= |
¤£µ¥©ó |
|
!, t¸¹ (-), ++, -- |
|
¼ ( * )¡B°£ ( /
)¡B¾l¼Æ( % ) |
|
¥[ ( +)¡B´î ( - ) |
|
<, <=, >, >= |
|
==, != |
|
&& |
|
|| |
°ò¥»¹Bºâ¤lÀu¥ý¶¶§Çªí