
实现上述功能的 VB 代码如下。
Const n = 5 'n=5 为例
Dim a(1 To n) As Integer '用于记录每个数组元素的值
Dim b(1 To n) As Integer '用于记录每个数组元素在原数组中的下标
Private Sub Form_Load()
'读取一组正整数,存储在数组 a 中
'将每个数组元素在原数组中的下标存储在数组 b 中
'将数组元素显示在列表框 List1 中
'代码略
End Sub
Function Getans() As Integer
Dim left As Integer, ans As Integer
left = 10000: ans = 0
For i = 1 To n
If b(i) < left Then left = b(i)If b(i) - left > ans Then ans = b(i) - left
Next i
Getans = ans
End FunctionPrivate Sub Command1_Click()
Dim i As Integer, j As Integer, t As Integer
For i = 1 To n
For j = n To i + 1 Step -1If

t = a(j): a(j) = a(j - 1): a(j - 1) = t
t = b(j): b(j) = b(j - 1): b(j - 1) = t
End If
Next j
Next i
Text1.Text = ▲End Sub
(1)代码“Private Sub Command1_Click()”中表示加载在 Command1 上的事件是_______________ 。(单选,填字母:
A.Click/ | B._Click/ | C.Command1_Click) |
(3)程序代码中,将 Text1.Text 赋值语句补充完整__________________。
(4)如程序运行界面所示数据,单击命令按钮 Command1 后,数组元素 b(2)的值为____________。

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

