编写如下程序: Dim num As Integer, r As Integer, n As Integer, i As Integer Dim arr(5) As Integer Private Sub Command1_Click() num =

admin2020-07-22  37

问题 编写如下程序:
Dim num As Integer, r As Integer, n As Integer, i As Integer
Dim arr(5) As Integer
Private Sub Command1_Click()
   num = 12:   r = 2
   Call sub1(num, r, n)
   For i = n To 1 Step -1
      Print arr(i);
   Next i
End Sub
Sub sub1(d As Integer, r As Integer, k As Integer)
   k = 0
   Do While d <> 0
      k = k + 1
      arr(k) = d Mod r
      d = d \ r
   Loop
End Sub
程序运行后,单击命令按钮Command1,输出结果为

选项 A、1  1  0  0
B、0  0  1  1
C、0  1  0  1
D、1  0  1  0

答案A

解析 sub1函数对全局数组arr元素赋初值,sub1函数参数传递均为默认的引用传递。因此执行完后n值被修改。Command1_Click()事件中的For循环对arr数组元素进行倒序输出。选A。
转载请注明原文地址:https://kaotiyun.com/show/2WHp777K
0

最新回复(0)