[單項(xiàng)選擇題] 單擊命令按鈕時(shí),下列程序的執(zhí)行結(jié)果是 Private Sub Command1_Click() Dima As Integer,b As
[單項(xiàng)選擇題] 單擊命令按鈕時(shí),下列程序的執(zhí)行結(jié)果是
Private Sub Command1_Click()
Dima As Integer,b As Integer,c As Integer
a=3:b=4:c=5
Print SecProc(c,b,a)
End Sub
Function FirProc(x As Integer,y As Integer,z As Integer)
FirProc=2*x+y+3*z+2
End Function
Function SecProc(x As Integer,y As Integer,z As Integer)
SecProc=FirProc(z,x,y) +x+7
End Function
A) 20 B) 25 C) 37 D) 32
A. 20
B. 25
C. 37
D. 32
正確答案:C
參考解析:此題程序代碼中用了嵌套調(diào)用,我們對(duì)這樣的問(wèn)題要多加小心,千萬(wàn)不要把實(shí)參和相對(duì)應(yīng)的形參弄混。主調(diào)過(guò)程Commandl_Click輸出的是SecProc(c,b,a) 的返回值,調(diào)用過(guò)程SecProc時(shí),主調(diào)過(guò)程分別把實(shí)參c、b、a地址傳給形參x、y、z,此時(shí)在過(guò)程SecProc中,SecProc=FirProc(a,c,b)+7。由此看出,程序段執(zhí)行此語(yǔ)句時(shí),將調(diào)用過(guò)程FirProc。把實(shí)參a,c,b的地址分別傳給形參x、y、2,此時(shí)在過(guò)程FirProc中,F(xiàn)irProc=2*x+y+3*z+2,所以FirProc(a,c,b)=6+4+15 +2=27,SecProc(a,c,b) =27+3+7=37。
詞條內(nèi)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢(xún)相關(guān)領(lǐng)域?qū)I(yè)人士。