问题描述:
How many times will the body of the following loop be executed?
int sum = 0;
int n;
for (n = 9; n > 0; n = n / 2)
sum = sum + n;
(a) once
(b) twice
(c) four times
(d) three times
为什么答案是三次呢?不是四次么?n=9,4,2,1各一次?
int sum = 0;
int n;
for (n = 9; n > 0; n = n / 2)
sum = sum + n;
(a) once
(b) twice
(c) four times
(d) three times
为什么答案是三次呢?不是四次么?n=9,4,2,1各一次?
问题解答:
我来补答展开全文阅读