【单选】15.根据某场馆一天中每位参观者的进馆和出馆时间,可统计该场馆当天人流量的分布情况。每个人进、出馆的时间用一个长度为11的字符串表示,例如“08:05-08:45”表示进馆时间为8点5分,出馆时间为8点45分。现要求统计当天馆内人数超过指定人数的总时长。
根据上述要求编写VB程序,功能如下:读取n个人进,出馆的时间,显示在列表框List1中。程序运行时,在文本框Text1中输入指定人数,单击“统计”按钮Command1,在标签Label1中显示馆内人数超过指定人数的总时长。程序运行界面如图所示。
(1)在VB表达式Va1(Text1.Text)中,Va1、Text1、Text依次表示______(单选,填字母:A.方法名、属性名、事件名/B.函数名、对象名、方法名/C.函数名、对象名、属性名)。
(2)实现上述功能的VB程序如下,请在划线处填入合适的代码。
(3)程序中加框处代码有错,请改正。______
Const n = 800
Dim d(1 To n)As String,a(1 To 2 * n)As String
Private Sub Form_Load()
’读取n个人进、出馆的时间,存入数组d并显示在列表框List1中,代码略
End Sub
Private Sub Command 1_ Cliek()
Dim i As Integer,j As Integer,k As Integer,sp As Integer
Dim i As Integer,cnt As Integer,mts As Integer,sum As Integer
Dim s As String
’提取每个人的进,出馆时间,分别加上IN、OUT标记后存入数组a
For i = l To n
a(i)=Mid(d(i),1,5)+"IN"
= Mid(d(i),7,5)+"OUT"
Next i
For i = 1 To 2 * n-1 对数组元素a(1)到a(2*n)从小到大排序
__
For i = i To 2 * n-1
If a(j) < a(k) Then k = j
Next j
s = a(i):a(i) = a(k):a(k)=s
Next i
sp =Val(Text1,Text)
t=-1:cnt=0:sum=0
For i = 1 To 2 * n
mts=Val(Mid(a(i),1,2))*60+Val(Mid(a(i),4,2))
If Mid(a(i),6,2)=“IN” Then cnt = cnt + 1 Else __
If cnt > sp Then
If t = -1 Then t = mts
Elself t > -1 Then
__
t=-1
End If
Next i
Label1.Caption = "超过指定人数的总时长:"+Str(sum)+"分钟"
End Sub
正确答案:B,您的答案:B,回答错误。
【解析】
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum
laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin
sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus
mollis orci, sed rhoncus sapien nunc eget odio.