水果编号 | 水果名称 | 单位 | 单价 | 入库数量 | 入库日期 | 审核 |
A001. | 红富士苹果 | 箱 | ¥75.00 | 50 | 2021/12/21 | 已审核 |
A002 | 阿克苏苹果 | 箱 | ¥80.00 | 100 | 2021/12/26 | 未审核 |
A001 | 红富士苹果 | 箱 | ¥75.00 | 100 | 2021/12/23 | 未审核 |
…… | …… | …… | …… | …… | …… | …… |
下列关于“水果进货”数据表的描述,正确的是( )
Key = Val(Text1.Text)
i= l:j= Key
Do While i<= j
m=(i+j)\2 '①
If Key=m*m Then Exit Do 'Exit Do表示退出循环
If Key>m* m Then i=m+ 1 Else j=m- 1
Loop
If i> j Then
Label1.Caption= Key & "不是完全平方数"
Else
Label1.Caption= Key & "是完全平方数"
End If
运行该程序段,在文本框Text1中输入15,运行后①处语句的执行次数是( )
c= a(1): cnt= 0
For i= 1 To
If Then c= a(i)
If Then cnt= cnt+ 1 Else cnt= cnt- 1
Next i
Text1.Text= "出现次数过半的值是: " &c
上述程序段3个方框处的代码分别为( )
请回答下列问题:
请回答下列问题:
编写VB程序,实现上述功能。运行程序,在列表框List1中显示n个英文单词(单词仅由小写字母组成且字母个数至少为1),单击“统计”按钮Command1,在列表框List2升序显示全部单词的按键组合,在文本框Text1中显示最频繁使用的按键组合,若有多个,则全部输出。程序运行界面如图b所示。
'n为常量,代码略
Dim a(1 To n) As String '数组a存储所有单词
Dim b(1To2*n) As String '数组b存储转换后的按键组合
Private Sub Form_ Load()
'读取所有单词存入数组a,并显示在列表框List1中
'初始化数组b各元素为空字符串,代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, p As Integer, max As Integer
Dim m As Integer, key As String, t As String, s1 As String, s2 As String
key= 222334455566677889999 'key 表示a-z各个字母所对应的键盘数字
max=0
'以下代码实现将数组a中的每个单词转化成按键组合,并依次存入数组b中
For i= 1 To n
t= ""
For j= 1 To Len(a(i))
m = Asc(Mid(a(i), j, 1))- Asc("a")
t=
Next j
b(i)= t
Next i
'以下代码实现对数组元素b( 1)~b(n)升序排序
Do While i>=1
For j= 1 To i
If b(j+ 1)< b(j) Then
t=b(j+ 1): b(j+ 1)= b(j): b(j)=t
End If
Next j
i=i- 1
Loop
'将排序后数组元素b(1)~b(n)显示在列表框List2中,代码略
s1= b(1)
p=n+ 1
i= 1:j= 2
Do While j<= n '从数组元素b(n+1)开始存储最高频次的按键组合
s2 = b(j)
If s1 < s2 Then
If Then
max=j-i
p=n+ 1
b(p)=s1
Else If max=j- i Then
p=p+ 1
b(p)= sl
End If
s1= s2
End If
j=j+ 1
Loop
t=""
If max<j- i Then
t= s1
Else
For k=n+ 1 To p
t=t+ b(k)+" "
Next k
If max=j- I Then t=t+" "+s1
End If
Text1.Text= "最频繁按键组合为: " &t
End Sub
编写VB程序,实现上述功能。运行程序,在列表框List1中显示全部图书编号。单击“整理”按钮Command1,在标签Label1中显示待调整区间图书的册数,在文本框Text1中显示待调整区间图书的起止编号,并在列表框List2中显示排序后的图书编号。程序运行界面如图所示,其中①和②两处分别指向待调整区间图书的起始和截止编号。
'n是常量,代码略
Dim a(0 To n) As String
Private Sub Form_ Load()
a(0)= "”
'将n册图书的编号存入数组元素a(1)~a(n),在List1中显示,代码略
End Sub
Private Sub Command1_ Click()
Dim i As Integer, k As Integer, left As Integer, right As Integer
Dim min As String, max As String
min= ": max= ": left= 1: right= 0
For i= 1 To n- 1
If a(i)> a(i + 1) Then
max = a(i)
left= i: Exit For
End If
Next i
For i=n To 2 Step-1
If Then
min= a(i)
right= i: Exit For
End If
Next i
i= left
Do While i <= right
If a(i)> max Then
max = a(i)
ElseIf a(i) < min Then
min= a(i)
End If
i=i+ 1
Loop
k=0
If left < right Then
left = getPos(1, left, min)
k= right- left+ 1
Text1.Text= "待调整区间图书起始编号: " + a(left) + "-->截止编号: "+ a(right)
End If
Label1.Caption = "待调整区间图书共有:" + Str(k) + "册"
'对待调整区间的图书编号进行排序,在List2中输出整理结果,代码略
End Sub
Function getPos(head As Integer, tail As Integer, value As String) As Integer
Dim i As Integer
i= tai1
Do While
i=i- 1
Loop
getPos=i+ 1
End Function