作者meya (落寞之心)
看板Examination
标题Re: [考题] 计算机概要-程式问题
时间Tue Dec 11 17:53:35 2012
※ 引述《mingrong2 (mingrong)》之铭言:
: 1.
: #include<stdio.h>
: int main()
: { int a=2,b=5;
: a+=a++*--b;
: printf("%d\n",a);
: }
: (A)9 (B)10 (C)11 (D)13
: 答案:(C)
: 但是我算出来答案是B,
: 2+(2*4)=10,不知道是哪个地方错误!!
是在printf()这个函式内计算错误
a= a+ a++* --b ;
t5 t3 t1 t2 t4... 时间点
t1时a=2,t2时a=2,t3时a=2,t4时a=2,t5时a=2+2*4=10
printf("%d\n",a);
t6
t6时a=11
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.136.166.143
※ 编辑: meya 来自: 220.136.166.143 (12/11 17:54)
1F:→ orientorient:不是已经解过了... 还回文是?? 12/11 18:28
2F:推 asdd:这样写不是更容易"了解"问题所在吗!! 12/11 22:01
3F:→ orientorient:要这样写才了解喔... 12/12 07:26
4F:→ orientorient: 更 12/12 07:26