下列程序段运行结束后,变量X的值是______。
x=2
y=2
Do
x=x*y
y=y+1
Loop While y<4
A.4
B.12
C.48
D.192
参考答案:B
解析: 程序中使用了Do…While循环,循环体至少执行一次,循环继续执行的条件是y<4。循环体中x=x*y=2*2=4,y=y+1=3,条件满足循环体继续执行,x=4*3=12,y=3+1=4,此时条件不满足,不再执行循环体,循环结束。
下列程序段运行结束后,变量X的值是______。
x=2
y=2
Do
x=x*y
y=y+1
Loop While y<4
A.4
B.12
C.48
D.192
参考答案:B
解析: 程序中使用了Do…While循环,循环体至少执行一次,循环继续执行的条件是y<4。循环体中x=x*y=2*2=4,y=y+1=3,条件满足循环体继续执行,x=4*3=12,y=3+1=4,此时条件不满足,不再执行循环体,循环结束。
根据短文内容,完成表格。 | ||||||
Do you want to go to Beijing? Let me introduce the ways from Shanghai. The train fare (价格) is 230 yuan, the bus fare is about 300 yuan, the taxi fare is about 580 yuan, and the plane fare is about 2,240 yuan. You see, the cheapest (最便宜的) way is by train. But it takes the most time. It takes you two days to get to Beijing. But taking a plane is about three hours' flight. It's about eight hours' drive by taxi and you need one day by bus. | ||||||
|