以下是一个能返回数组a中最大数的函数过程代码: Function maxval(a() As Integer) As Integer Dim max% max = 1 For i = 2 To 10 If a(i) > a(max) Then max = i Next i maxval = max End Function Private Sub Command1_Click() Dim x(1 To 10) As Integer For i = 1 To 10 x(i) = Int(Rnd() 1
以下是一个能返回数组a中最大数的函数过程代码: Function maxval(a() As Integer) As Integer Dim max% max = 1 For i = 2 To 10 If a(i) > a(max) Then max = i Next i maxval = max End Function Private Sub Command1_Click() Dim x(1 To 10) As Integer For i = 1 To 10 x(i) = Int(Rnd() 100) Print x(i); Next i Print Print maxval(x())End Sub程序运行时,发现函数过程的返回值是错的需要修改,下面的修改方案中正确的是()。
A.语句“max = 1”应改为“max = a(1)”
B.语句“For i = 2 To 10”应改为“For i = 1 To 10”
C.If语句“max = i”应改为“max = a(i)”
D.语句“maxval = max ”应改为“maxval = a(max)”
正确答案: D
Tag:VisualBasic程序设计 语句 函数
时间:2021-11-29 15:20:45
- 上一篇:有如下函数过程:Function Cys(ByVal x As Integer, ByVal y As Integer) As Integer Dim quotients Do While y <> 0 quotients = x / y x = y y = quotients Loop Cys = xEnd Function以下是调用该函数的事件过程,该程序的运行结果是()。Private Sub Command1_Click() Dim a As Integer Dim b As Inte
- 下一篇:在窗体上画一个命令按钮(名称为Command1),并编写如下代码:Function Fun1(ByVal a As Integer, b As Integer) As Integer Dim t As Integer t = a – b b = t + a Fun1 = t + bEnd Function Private Sub Command1_Click() Dim x As Integer x = 10 Print Fun1(Fun1(x, (Fun1(x, x – 1))), x – 1)End