
图a

图b
编写程序找出青蛙成功过河至少需要增加的荷叶数,界面如图b。请回答以下问题:
(1)若要将列表框List1顶端与窗体顶端的距离设置为100,能实现该功能的语句是____(A.List1.Height = 100 / B.List1.Top = 100 / C.List1.Width = 100)。
(2)实现上述功能的VB程序如下,请在划线处填入合适的代码。
Private Sub Form_Load()

'读取荷叶的位置,并保存到数组a中
'荷叶的数量保存在n中
'荷叶坐标和数量分别显示在list1和Text2中
End Sub
Private Sub Command1_Click()
Dim a(0 To 100) As Integer
Dim n As Integer, L As Integer, W As Integer, tot As Integer
Dim i As Integer, j As Integer, p As Integer, d As Integer
L = Val(Text1.Text) : n = Val(Text2.Text) : W = Val(Text3.Text)
a(0) = 0 : a(n + 1) = ______
For i = 1 To n - 1
k = i
For j = i + 1 To n
If a(k) > a(j) Then

Next j
If k <> i Then
tmp = a(k): a(k) = a(i): a(i) = tmp
End If
Next i
For i = 1 To n
List1.AddItem a(i)
Next i
p = 1: d = 0
Do While d < L
If p <= n + 1 And ______ Then
d = a(p)
p = p + 1
Else
tot = tot + 1
_______
End If
Loop
Label4.Caption = "至少需要增加的荷叶数为:" + Str(tot)
End Sub
(3)程序中加框处代码有错,请改正______。

同类型试题

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

