解题思路:随机生成10条船的载重量[1,10]和费用[1,30],然后将它们按费用从小到大排序,若费用相同,则载重大的在前,运输时,先把费用低的船装满,再按费用向下将船装好,运输。
图a
(1)根据上图a所示,可以发现有_________(填数字)个对象没有caption属性。
(2)根据上述描述设计如下VB程序,请在划线处填入合适的代码。
Dim f(1 To 10)As Integer, w(1 To 10)As Integer, b(1 To 10)As Integer
Private Sub Command2_Click()
Dim n As Integer, count As Integer, yf As Integer
Dims As String, i as integer
n = Val(Text1.Text)
count = 0
yf = 0
cz = n
i = 1
Do While n > 0
If n >= w(b(i))Then
____
Else
yf = yf + n*f(b(i))
End If
count=count+1
s = s + Str(b(i))+ "号船"
i=i+1
____
Loop
Label2.Caption="总计费用为:"+ Str(yf)+ "元" + Str(count)+" 条船,分别为"+s
End Sub
Private Sub form_load()
Dim t As Integer, i as integer, j as integer
Listl. Clear
List1. AddItem "编号载重费用'"
For i=1 To 10
w(i)= Int(Rnd*10+1)
f(i)= Int(Rnd*30+1)
b(i)=i
Listl. Addltem Str(b(i))+ " " + Str(w(i))+ " " + Str(f(i))
Next i
For i=1 To 9
For j=10 To i+1 Step-1
If ____Then
t=b(j):b(j)=b(j-1):b(j-1)=t
End If
Next j
Next i
End Sub

同类型试题

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

