修改时间:2024-07-13 浏览次数:95 类型:期中考试
图a
(提示:=COUNTIFS(B3:B85,“>=2018”,D3:D85,“>=80”)表示统计B3:B85区域大于等于2018,并且D3:D85区域大于等于80的单元格数量)
图b
图a
图b
图c
程序界面如图所示,左边列表框List1中显示的是部分职工的卡号和余额,在文本框Text1中输入职工的IC卡号,单击“查询余额”按钮(Command1)后,如果找到此卡号,则在标签Lab3中显示“此卡号余额为”和对应的余额值,如果未找到则显示“找不到此卡号,请重新输入”。
解决此问题的部分程序段如下:
Const n=500' 设卡号总数为500
Dim zg(1 To n) As Long
Dim ye(1 To n) As Single
Private Sub Form1_Load()
' 此过程用于对数组zg和数组ye进行初始赋值,代码略
End Sub
Private Sub Command1_Click()
Dim x As Long, i As Long, j As Long, m As Long, find As Boolean
x=Val(Text1.Text)
i = 1 : j = n : find = False
Do While ‘改错
m = Int((i + j) / 2
If x = zg(m) Then
①
Else If ② Then
j = m - 1
Else
i = m + 1
End If
Loop
If find = true Then
Lab3.Caption=″此卡号余额为″+Str(ye(m))+″元″
Else
Lab3.Caption=″找不到此卡号,请重新输入″
End If
End Sub
程序中①画线处应填入。
程序中②画线处应填入。
原1-7号男生身高 |
171 172 180 174 176 179 178 |
筛选排序后序列 |
171 172 174 176 178 179 180 |
“造型设计”后序列 |
180 178 174 171 172 176 179 |
图1
身高顺序:男3号〉男6号〉男7号〉男5号〉男4号〉男2号〉男1号
图2
Dim h (1 To n) As Integer
Dim height1(1 To n) As Integer
Dim height2(1 To n) As Integer
Dim n As Integer,i As Integer, j As Integer, num As Integer ,tmp As Integer
Dim sex(1 To n) As String
Private Sub Form_Load()
'n名学生的身高和性别由数据库导出,分别存储在数组h 和sex中,代码略!
End Sub
Private Sub Command1_Click()
b = 0
For i = 1 To n 'n名学生中的男生
If sex(i) = “男” Then ① : height1(num) = h(i)
Next i
For i = 1 To num - 1
For j = num To i + 1 Step -1
If height1(j) < height1(j - 1) Then
tmp = height1(j): height1(j) = height1(j - 1): height1(j - 1) = tmp
End If
Next j
Next i
For i = 1 To num
Text1.Text = Text1.Text + " " + Str(height1(i))
Next i
End Sub
Private Sub Command2_Click()
Dim left, right As Integer, i As Integer, mid As Integer
mid = Int((1 + num) / 2)
left = 0: right = 0
height2(mid) = height1(1)
For i = 1 To (num - 1) \ 2
right = right + 1
height2(mid + right) = height1(2*i)
left = left + 1
②
Next i
If num Mod 2 = 0 Then ③
For i = 1 To num
Text2.Text = Text2.Text + " " + Str(height2(i))
Next i
End Sub
程序中①画线处应填入;
程序中②画线处应填入;
程序中③画线处应填入;
试题篮