s=1
a(1) = 1
For i=2 To 6
a(i) =2*i+a(i-1)
If I Mod 2=0 Then
a(i)=a(i)+1
End If
s= s+ a(i)
Next i
Text. Text = Str(s)
程序运行时,单击按钮Command1后,文本框Text1中显示的内容是( )
For i=1 To 3
k=i
For j=i+1 To 8
If a(j)<a(k) Then k=j
Next j
If k<> i Then
t=a(k):a(k)=a(i):a(i)=t
End If
Next i
数组元素a(1)到a(8)的值依次为“8,13,20,2,11 ,30, 25,17”,下列说法不正确的是( )
s = Text1. Text
k = Val(Text2. Text)
i=1
count = 0
flag = False
Do While i<= Len(s)
count = count+1
If i+k- 1 <= Len(s) And flag Then
Else
ns= ns+ Mid(s,i,1)
i=i+1
End If
If count = k Then
count = 0
If flag = True Then
End If
Loop
Labell. Caption = ns
Key = Val(Text1. Text)
i= 1:j=10:c= 0
flag = True
Do While i<= j And flag
m= (i+j)\2
cnt=cnt+1
If a(m) = Key Then flag = False
If a(m) < Key Then
i=m+1
ElseIf flag Then
j =m-1
End If
Loop
Text2. Text = Str(cnt)
若数组元素a(1)~a(10)的值依次为“5,9,13,18,22,27,31,39,40,44" ,运行程序后,文本框Text2中显示的内容为3,则输人的key值不可能为( )
(提示:各销售渠道销售总额在2021年度总销售额中的占比=各销售渠道销售总额/2021年度总销售额* 100)
“音乐”图层中的声音在动画开始播放约1秒后才开始播放,为使音乐从动画一开始即播放,可以执行的操作是 。
编写一个VB程序实现如下功能:程序运行后自动读取数据库中关于食堂套餐的相关数据,在文本框Text1中输人查找套餐的关键词,搜索到的套餐信息在列表框List1中显示,程序计算套餐平均评分(四舍五入保留一位小数)和推荐指数,并显示在套餐信息下方。程序运行界面如图所示。
Const n = 50
Dim food(1 To n) As String
Dim price(1 To n) As Integer
Dim score(1 To n) As Single
Private Sub Form_ Load()
‘读取数据库中套餐名称、套餐价格和套餐评分信息分别存储于数组food、price和score中,代码略。
End Sub
Private Sub Command1 _Click()
Dim food(1 To n) As String, s As String
Dim price(1 To n) As Integer
Dim judge(1 To n) As Boolean
Dim score(1 To n) As Single, sum As Single, ave As Single
Dim i As Integer, j As Integer, t As Integer, q As Integer
Dim w1 As Boolean, w2 As String, w3 As Integer, w4 As Single
s = Text1.Text : q= 0
For i=1 To n
①
j= 1
Do While True
If j+Len(s)-1<=t Then
If s = Mid( food(i), j, Len(s)) Then
judge(i) = True
q=q+1
Else
②
End If
End If
If Then
Exit Do
End If
Loop
Next i
For i=1 To n-1
For j=n To i+1 Step -1
If Not judge(j-1) And judge(j) Then
w1 = judge(j): judge(j) = judge(j-1): judge(j-1) = w1
w2 = food(j): food(j) = food(j - 1): food(j-1) = w2
w3 = price(j): price(j) = price(j -1): price(j-1) = w3
w4 = score(j): score(j) = score(j-1): score(j -1) = w4
End If
Next j
Next i
For i= ③
List1. AddItem food(i) +Str( price(i))+"元"
sum =sum+score(i)
Next i
ave = Int(sum/ q * 10 +0.5) / 10
‘根据平均评分ave 的值给出推荐指数。若平均评分高于4.5分显示推荐指数"* **",若平均评分高于4.0分显示推荐指数"* *",4.0分以下的显示推荐指数" *",代码略。
End Sub
①②③
编写一个VB程序实现如下功能:单击“开始循迹”按钮Command1,呈现10*10矩阵地图,并随机生成4个循迹点,分别用数字1表示,数字0表示非循迹点;计算4点中相距最远的两点的直线距离,显示在标签Label1中。程序运行界面如图b所示。
Const n = 10
Const m=4
Dim b(1 To 8) As Integer
Private Sub Command1_Click()
Dim f(1 To n* n) As Integer
Dim i As Integer, j As Integer
Dim w As Integer, k As Integer
Dim length As Single, maxlen As Single
Dim s As String
'生成矩阵地图和随机生成4个循迹点,0表示非循迹点,1表示循迹点,存于数组f中,代码略。
For i= 1 To n^2 '显示矩阵地图和4个循迹点
s = s+ Str(f(i))
If i Mod n=0 Then
List1. AddItem s
s=" "
End If
Next i
w=1
For i=1 To n
For j=1 To n
k = (n+1)* ((i-1) Mod 2)+(-1)-(i-1) * j
If Then '记录循迹点所在位置
b(2*w-1)=i
b(2*w)=k
w=w+1
End If
Next j
Next i
i=1
maxlen = 0
Do While i<=m-1
For j=i+1 To m
If length > maxlen Then maxlen = length
Next j
i= i+1
Loop
Label1. Caption = Str( maxlen)
End Sub
Function reck(x As Integer, y As Integer) As Single
Dim c As Integer, d As Integer
Dim h As Single
c=
d=Abs(b(2*x)-b(2*y))
h=Sqr(c^2+d^2)
reck = h
End Function