a(1)=1:a(2)=1
b(1)=1:b(2)=2
For i=3 To 5
a(i)=a(i-1)+a(i-2)
b(i)=b(i-1)+a(i)
Next i
执行该程序段后,数组元素b(5)的值为( )
Function f(n As Integer)As Long
Text1.Text=Trim(Str(n))+Text1.Text ‘函数Trim的作用是去掉字串首尾空格
If n=1 Then
f=1
Else
f=3*f(n\2)
End If
End Function
Private Sub Command1_Click()
Text1.Text=“”
Text1.Text=Trim(Str(f(8)))+Text1.Text
End Sub
单击按钮Command1后,文本框Text1中显示的值是( )
Private Sub Command1_Click()
Dim k As Integer,a As Integer,b As Integer
a=Val(Text1.Text)
b=Val(Text2.Text)
Label1.Caption=trans(a,b)
End Sub
Function trans(m As Integer,n As Integer)As String
If m<>0 Then
r=m Mod n
trans=trans(m\n,n)+Str(r)
Else
trans=0
End If
End Function
程序运行时,在文本框Text1和Text2中分别输入11和2,则Label1中的输出结果是( )
Private Sub Command1_Click()
Dim x As Integer
x=Val(Text1.Text)
Label1.Caption=Str(x) & prime(x,2)
End Sud
Function prime(n A Integer m A Integer)As String
If n=m Then
prime=“是素数。”
ElseIf n<2 Or n Mod m=0 Then
prime=“不是素数。”
Else
prime=prime(n,m+1)
End If
End Function
在文本框Text1中输入的值是123,并执行程序后,自定义函数prime( )被执行的次数是( )
Dim a(1 to 1000)as long, n as integer
n=Val(Text1.Text)
a(1)= 1:a(2)= 1
For i=3 to n
a(i)= a(i-1)+a(i-2)
Next i
Label1.Caption=“斐波那契的第”&Str(n)&“是”&a(n)
该程序用到了下列哪一个算法( )
Function s(n As Integer) As Integer
If n=1 Then
s=1
Else
s=s(n-1)+n
End If
End Function
Private Sub Form_Click()
Dim x As Integer
x=s(4)
Print x
End Sub
程序运行时,单击窗体后,变量x的值为( )
Function f(i As Integer)
If i=1 Then
f=2
Else
f=2 * 10 ^ (i-1)+f(i-1)
End If
End Function
Private Sub Command1_Click()
Dim n As Integer, s As Integer, i As Integer
n=Val(Text1.Text)
s=0
For i=1 To n
s=s+f(i)
Next i
Label1.Caption=Str(s)
End Sub
若在Text1中输入5,则Label1显示的内容为( )
Function fact(n As Integer) As String
If n = 1 Then
fact = fact & 1
Else
fact = fact(n \ 2) & n Mod 2
End If
End Function
Private Sub Command1_Click()
Dim x As String, i As Integer, r As Integer
x = Text1.Text
For i = 1 To Len(Text1.Text)
If Mid(x, i, 1) = "." Then Exit For Next i
r = Val(Mid(x, i + 1, Len(Text1.Text) - i)) Text2.Text = fact(r)
End Sub
在文本框Text1中输入2019.70,则执行程序段,在文本框Text2中显示的内容是( )
Private Sub Command1_Click()
Dim y As Long
Text1.Text = ""
y = f(3)
Label1.Caption = Str(y)
End Sub
Function f(n As Integer) As Long
Text1.Text = Text1.Text + Str(n)
If n <= 1 Then
f = 1
Else
f = f(n - 1) + 2
End If
End Function
Dim a(1 To 10) As Integer
Function Search(L As Integer, R As Integer) As Integer
M = (L + R) \ 2
If a(M) < a(M - 1) And a(M) > a(M + 1) Then
⑴
ElseIf a(M) > a(M - 1) And a(M) > a(M + 1) Then
⑵
ElseIf a(M) > a(M - 1) And a(M) < a(M + 1) Then
⑶
End If
End Function
Private Sub Command1_Click()
Label1.Caption = "“峰顶”值是:" + Str(Search(1, 10))
End Sub
上述程序中划线处可选语句为:
①Search = Search(M + 1 , R)
②Search = Search(L , M - 1)
③Search = a(M)
则(1)(2)(3)处的语句依次是( )
Function t(x As Integer) As Long
If x = 1 Then t = 1
ElseIf x = 2 Then
t = 2
Else
t = t(x - 1) + t(x - 2)
End If
End Function
Text1.Text = Str(t(8))
执行该程序段后,文本框 Text1 中显示的内容是( )。
Function ZF(S As String) As String
Dim n As Integer
n = Len(S)
If ⑴ Then
ZF = ⑵
Else
ZF = Mid(S, n, 1) + ZF(Mid(S, 1, n - 1))
End If
End Function
Private Sub Command2_Click()
Dim x As String
x = Text1.Text
Text2.Text = ZF(x)
End Sub
该程序采用的算法和划线处应该填入的内容分别为( )
Private Sub Command1_Click( )
Dim m,n As Integer
m=Val(Text1.Text)
n=Val(Text2.Text)
Text3.Text= ①
End Sub
Function gcd(x, y As Integer)As Integer
Dim z As Integer
z=x Mod y
If z=0 Then
gcd= ②
Else
gcd=gcd(y, z)
End If
End Function
以上程序段运行时,为了实现上述功能,画线处应填入的代码分别为:①;②。
Function fx(n As Integer) As Long
If n=1 Then
fx=2
Else
fx=2+fx(n-1)
End If
End Function
Private Sub Command1_ Click()
Dim x As Integer, y As Integer
x=va1(Text1. Text)
y=fx(x)
Text2. Text= Str(y)
End Sub
程序运行时,在文本框Text1中输人数字10,单击命令按钮后,在Text2显示内容为( )
图b为标准ASCII码表供你参考(其中ASCII为1-32,127的字符为特殊符号,不能用作密码):
实现上述功能的VB程序代码如下,请回答以下问题:
Private Sub Command1_Click()
Dim t As Integer, flag as Boolean
Dim pwd as String ,n as Integer
Dim a(1 To 4) As Integer
flag= True
n=0
pwd=" "
Randomize
Do While flag
t= '随机生成33~126的ASCII码
pwd= pwd+Chr(t)
s= 0
For i=1 To 4
s=s+a(i)
Next i
n=n+1
If n>=6 And s=4 Then
Loop
Text1. Text= pwd
End Sub
'获取字符类型:1-小写字母,2-大写字母,3-阿拉伯数字,4-符号
Function check(x As Integer) As Integer
If x>=97 And x <= 122 Then
check= 1
ElseIf x >=65 And x <=90 Then
check= 2
ElseIf x>=48 And x <=57 Then
check= 3
Else
check= 4
End If
End Function
①H2? N64Aj
②[26wv9,Q
③$ 14G/uv④zX}rb! T&}d2