例如:单词banana由b,a,n三个字母组成,其中a字母出现了3次,n字母出现了2次,b字母出现了1次,得到maxn为3,minn为1,maxn与minn的差为2,是一个素数,那么banana就是一个幸运单词。
编写一个判断幸运单词的VB程序,在文本框Text1中输入一个单词(注:仅输入小写字母,且长度小于100),单击“判断”按钮Command1,标签Labal1输出运行结果。
程序运行界面如图所示,实现上述功能的VB代码如下,但加框处代码有错,请改正。
Private Sub Command1_Click()
Dim maxn As Integer
Dim minn As Integer
Dim a(1 To 26)As Integer
maxn=0
minn=100
s= Text1.Text
n=Len(s)
For i=1 To n
dz=Mid(s,i,1)
If dz>=“a”And dz<=“z”Then
p=
‘(1)
a(p)=a(p)+1
End If
Next i
For j=1 To 26
If a(j)>0 Then
If a(j)>maxn Then maxn=a(j)
If a(i)<minn Then minn=a(j)
End If
Next j
If(maxn-minn>=1)And
Then ‘(2)
Label1.Caption=“幸运单词!”
Else
Label1.Caption=“无!”
End If
End Sub
‘自定义函数iszs(x)用于判断整数x是否为素数,如果x是素数返回True
Function iszs(x As Integer)As Boolean
‘代码略
End Fuction
Dim c As String, i As Integer
Dim s As String, s1 As String
s = "Jishu_Xuankao_2020"
s1 =""
For i = 1 To Len(s) Step 2
c = Mid(s, i, l)
If c >= "a" And c <= "z" Then s1=c+s1
Next i
Text1. Text = s1
执行该程序段后,文本框Text1显示的内容是( )
请在下列程序代码的基础上按照要求设计该程序,完善程序中的划线部分。
Dim n As Integer, a1 As Integer, a2 As Integer, a3 As Integer
Function f(x as integer) As Boolean
f=True
For i=2 To Sqr(x)
If x Mod i=0 Then
Next i
End Function
Private Sub Command1_Click()
n=
For a1=2 To n
For a2=a1 To n
For a3=a2 To n
IfAnd f(a1) And f(a2) And f(a3) Then
List1.AddItem(Str(a1)+“ ”+Str(a2)+“ ”+Str(a3))
End If
Next a3
Next a2
Next a1
End Sub

Private Sub Command1_Click()
Dim s As String, s1 As String, s2 As String
Dim c As Integer, k As Integer, i As Integer, flag As Boolean
flag = False: c = 0
s = Text1.Text
For i = 1 To Len(s)
If Mid(s, i, 1) = “=”Then Exit For
Next i
s2 = Mid(s,i+1,Len(s)- i)
k = Len(s1)
For i = 1 To k-1
If Val(Mid(s1, 1, i))+Val(Mid(s1, i + 1, k-i))=Val(s2) Then
List1.AddItem “第”+Str (c)+“种答案:”+Mid(s, 1, i)+“+”+Mid(s, i + 1, Len (s)-i)
flag = True
End If
Next i
IfThen List1.AddItem “没有答案!”
End Sub
For i =2 To 10
If a(i) < min Then min = a(i)
Next i
方框中最合适的语句是( )
i=1:j=n
Do While i+1<j
m=(i+j)\2
If a(m+1)-a(m)>a(m)-a(m-1)Then
Else
End If
Loop
Labell.Caption="相邻两个元素的最大差值是"+Str(a(j)-a(i))
上述程序段两个方框处的语句分别为( )
t=" ":i=0:j=9:key=62:f=False
Do While i<=j And Not f
m=Fix((i+j)/2)
t=t+Str(m)
If a(m)=key Then
f=True
Elself a(m)>key Then
i=m+1
t=t+"→"
Else
j=m-1
t=t+"←"
End If
Loop
数组元素a(0)到a(9)的值依次为“99,94,90,87,78,70,63,56,45,36”,执行该程序段,t的值是( )
s=Text1.Text
For i=1 To Len(s)
For j= ①
List 1.AddItem ②
Next j
Next i
为实现上述功能,程序段两个划线处的语句分别为 ( )
s=0
For i=1 To 10
s=s+i
Next i

Const nc=20 ‘班级总数
Constn= 8
Dim a(1 To n*nc) As Single
Dim sum(1 To 4) As Single ‘存储每个团队的总分
Dim q(1 To nc) As Integer ‘存储演出时班级出现的顺序
Private Sub Form_Load()
‘本过程读取班级号和6个打分情况存储到a数组中。a(1)存储第一个上台的班级号,a(2)~a(7)中存储该班的6个得分,a(8)预留出来,用来存储该班最终得分,初值为0;a(9)存储第二个上台的班级号,a(10)~a(15)中存储第二个上台班级的6个得分,a(16)预留,用来存储该班最终得分,初值为0,以此类推。在List1中输出班级号和6个得分,代码略。
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, s As String
For i=1 To n* nc ‘将每个班的6个得分排序
If i Mod n<>0 And i Mod n<>1 Then
k=i
For j=i+1 To
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
For i=1 To n* nc Step n ‘计算每个班的最终得分,存入相应位置
a(i+n-1)=(a(i+2)+a(i+3)+a(i+4)+a(i+5))/4
Next i
For i=1 To n* nc Step n ‘计算每个团队总分
Next i
For i=1 To n* nc Step n
k=a(i)
q(k)=i
Next i
For i=1 To nc
List2.Addltem Str(i)&" "&
Next i
s="甲:"+Str(sum(1))+"乙:"+Str(sum(2))+"丙:"+Str(sum(3))+"丁:"+Str(sum(4))
Label3.Caption=s
End Sub
Pirvate Sub Command1_Click()
a = Val(Text1.Text)
b = a * a + 1
Text1.Text = b
End Sub
程序运行时,在文本框Text1中输入2,连续两次单击命令按钮Command1后,Text1中显示的内容是( )
Private Sub Command1_Click()
Dim a(5) as Integer
Dim n as Integer, i as Integer
n=Val(Text1.Text)
i=0
a(1)=1: a(2)=1
For i=3 To n
a(i)=a(i-1)+a(i-2)
Next i
Label1.Caption=a(i)
End Sub
若在Text1中输入5,则点击按钮后的运行结果为( )
flag = True : p = 0
Key = 5
For i = 1 To Key - 1
L = i
Do While
M = (L + R) \2
p = p + 1
If i * i + M * M < Key * Key Then
L = M + 1
ElseIf i * i + M * M > Key * Key Then
R = M - 1
Else
Text2.Text = Str(i) + “” + Str(M) + “” + Str(key)
flag = False
i = Key
End If
Loop
Next i
If flag Then Text2.Text = “没有符合条件的整数勾股数对!”
上述程序段2个划线处的代码分别为( )
k1 = 1:k2= 10
For i=2 To 10
If a(i) < a(k1) Then
ElseIf a(i) < a(k2) Then
End If
Next i
Text1.Text = Str(a(k1)) + "," + Str(a(k2))
上述程序中方框处可选语句为:
①k1=i
②k2= i
③k2= k1
则⑴⑵⑶处语句依次是( )