看板 Examination 關於我們 聯絡資訊
考慮以下 C 程式 int fun (int *x) { *x += 4; return 4 * (*x) –2; } void main() { int x = 20, y = 30, w,z; w = fun(&x) + (x/2); z = fun(&y) + (y/2); printf(“%d,%d”, w,z); } 程式執行後,w, z 的值為何? a.48與151 b.106與151 c.104與133 d.48與133 答案為b 想請問各位高手他是怎麼運算的啊? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.231.93.28 ※ 文章網址: http://www.ptt.cc/bbs/Examination/M.1405498286.A.67A.html
godpam:w=4*24-2+24/2=106 07/16 16:22
godpam:z=4*34-2+34/2=151 07/16 16:22
fatty3321:這題出題老師其實還蠻溫柔的XD如果是我一定把a或c挑一個 07/16 16:24
fatty3321:改106XD 07/16 16:25
j16598231:x=20,呼叫後x變24。w=94+24/2 07/16 16:26
Kingofjungle:不懂原理的話GOOGLE CALL BY VALUE,CALL BY ADRESS 07/16 16:32