Dim a(1 To 10) As Integer, b(1 To 10) As Integer
Private Sub Command1_Click( )
Dim i As Integer, time As Integer, k As Integer
Dim c(1 To 20) As Integer, nc As Integer
c(1)=a(1) :nc= 1
For i=1 To 9 '删除起点重复数据后添加到数组c
If a(i)<>a(i+1) Then
nc=nc+1
End If
Next i
For i=1 To 10 '删除终点重复数据后添加到数组c
k= nc
Do While b(i) < c(k)
k=k- 1
Loop
If Then '非重复 数据(新停靠楼层)添加到数组c
For j=nc To k+1 Step -1
c(j+1)=c(j)
Next j
nc=nc+1
c(j+1)=b(i)
End If
Next i
time=(c(nc)-c(1)) *3+nc*8
Text1. Text="总时间--"+Str( time)+ "秒"
End Sub
Private Sub Form_ Load( )
'生成10批入的起止楼层,分别给数组a和b,并在列表框list1输出,代码略。
For i=1 To 9
For j=10 To i+1 Step -1
If a(j)<a(j-1)Or Then
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
For i=1 To 10
List2. AddItem Str(a(i))+Str(b(i))
Next i
End Sub