修改时间:2021-05-20 浏览次数:138 类型:开学考试
Dim t As Integer, s As String, i As Integer
s = "20PYt22hoN"
t = 0
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "a" And c <= "z" Then c = Chr(Asc(c) - 32)
If c >= "A" And c <= "Z" Then
t = t + 1
Else
t = t - 1
End If
Next i
Text1.Text = Str(t)
执行该程序段后,文本框Text1中显示的内容是( )
key = Val(Text1.Text)
i = 1: j = 9
Do While i < j
m = (i + j) \ 2
If Then
i = m + 1
Else
End If
Loop
Label1.Caption = Str(i)
已知数组a存储一组升序数“2,5,9,11,13,15,18,23”。要查找第一个大于key的元素的下标并输出,则下列选项中正确的是( )
请回答下列问题:
Private Sub Search_Click()
Const n = 12
Dim s As String, c As String
Dim i As Integer, t As Integer
Dim rs(0 To n) As Integer '数组rs存储班级人数
Dim bj(1 To n) As Integer '数组bj存储班级编号
Dim flag As Boolean
s = Text1.Text
t = 0
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "0" And c <= "9" Then
t = ①
flag = True
ElseIf flag = True Then
rs(t) = rs(t) + 1
flag = False
t = 0
End If
Next i
For i = 1 To n
bj(i) = i
Next i
For i = 1 To n-1
k = i
For j = i + 1 To n
If ② Then k = j
Next j
If k <> i Then
t = rs(k): rs(k) = rs(i): rs(i) = t
t = bj(k): bj(k) = bj(i): bj(i) = t
End If
Next i
For i = 1 To n
List1.AddItem Str(bj(i)) + "班有:" + " " + + "人"
Next i
End Sub
① ②
Dim a(1 To 100) As Integer
Dim m As Integer, n As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer, x As Integer
Dim s As String
m = Val(Text1.Text)
n = Val(Text2.Text)
Randomize
For i = 1 To m
For j = 1 To n
x = Int(Rnd * 10 + 1)
Next j
Next i
s = ""
For i = 1 To m * n
s = s + Str(a(i))
If i Mod n = 0 Then
List1.AddItem s
End If
Next i
End Sub
Private Sub Command2_Click()
Dim i As Integer, x As Integer, y As Integer
Dim key As Integer, flag As Boolean
key = Val(Text3.Text): flag = False
For i = 1 To m * n
If key = a(i) Then
x = (i - 1) \ n + 1
y =
list2.AddItem Str(key) + "的坐标为:第" + Str(x) + "行,第" + Str(y) + "列"
flag = True
End If
Next i
If Not flag Then
list2.AddItem "未查找到相应数据!"
End If
End Sub
试题篮