i=100:flag=False
Do While i>0 And Not flag
Loop
Text1. Text = Str(i\10)+Str(i Mod 10)
方框中的代码由以下三部分组成:
①j=22006+i*10 ②i=i-1 ③If(j Mod 37)*(j Mod 67)=0 Then flag = True
下列选项中,代码顺序正确的是( )
请回答下列问题:
请回答下列问题:
根据上述要求编写VB程序,功能如下:读取n个人进,出馆的时间,显示在列表框List1中。程序运行时,在文本框Text1中输入指定人数,单击“统计”按钮Command1,在标签Label1中显示馆内人数超过指定人数的总时长。程序运行界面如图所示.
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_ Click( )
Dim i As Integer,j As Integer,k As Integer,sp As Integer
Dim t As Integer,cnt As Integer,mts As Integer,sum As Integer
Dim s As String
‘提取每个人的进、出馆时间,分别加上IN、OUT标记后存入数组a
For i = 1 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 j = 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
ElseIf t > -1 Then
t=-1
End If
Next i
Label1.Caption = “超过指定人数的总时长:”+Sir(sum)+“分钟”
End Sub
小组成绩的计算规则是:若小组成员中得分最高的前k人得分都不低于k,且其他成员得分都不超过k,则该小组成绩为k。例如,第1小组共有8个成员,得分依次为“5,2,7,11,8,6,5,1”,由此可知最高的前5人得分为“11,8,7,6,5”,其他3人得分为“5,2,1”,因此该小组成绩为5。
按上述要求,编写VB程序,功能如下:在列表框List1中显示各小组每个成员的得分,单击“计算”按钮Command1,在列表框List2中显示成绩最高的小组编号及成绩(如果有多个小组并列最高,则全部显示)。
Const n = 6
Const m = 8
Dim a(n * m)As Integer
Dim c(m)As Integer,ans(n)As Integer
Private Sub Form_Load( )
‘读取n个小组每个成员的得分,按组别从小到大依次存入数组a,并显示在List1中
‘n(1)到a(m)存储第1小组m个成员的得分
‘a(m+1)到a(2*m)存储第2小组m个成员的得分
‘以此类推,代码略
End Sub
Private Sub Cummand1_Click( )
Dim i As Integer,p As Integer,g As Integer,maxg As Integer
maxg = -1
For i = 1 To n
g = GroupScore(i)
If g > maxg Then
maxg = g: p=1
ElseIf g = maxg Then
p=p+1
ans(p)=i
End If
Next i
For i = 1 To p
List2. AddItcm“第”+Str(ans(i))+“组,成绩:”+Str(maxg)
Next i
End Sulb
‘函数返回第w小组的成绩
Function GroupScone(w As Integer)As Integer
Dim i As Integer,k As Inteser
For i = 0 To m
c(i)=0
Next i
For i=(w-1)*m+1 To w *m
k=a(i)
If k > m Then
c(k)=c(k)+1
Next i
k=m
Do White c(k)< k And k>0
k=k-1
Loop
GroupScore=k
End Function