[填空題] 設(shè)有以下函數(shù)過(guò)程: Functio fun(m As Integer) As Integer Dim k As Integer, sum As I
2021-07-20
[填空題] 設(shè)有以下函數(shù)過(guò)程: Functio fun(m As Integer) As Integer Dim k As Integer, sum As Integer sum=0 For k=m To 1 Step -2 sum = sum+ k Next k fun=sum End Function 若在程序中用語(yǔ)句s=fun(10)調(diào)用此函數(shù),則s的值為 ______。
正確答案:30
參考解析:本題對(duì)函數(shù)過(guò)程的掌握情況。函數(shù)過(guò)程的功能是以步長(zhǎng)為-2,將m到1進(jìn)行累加,s=fun(10)語(yǔ)句將參數(shù)傳遞給函數(shù)過(guò)程,故結(jié)果為sum=10+8+6+4+2=30。
詞條內(nèi)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。