有如下VB程序其功能是实现正话反说(即将输入字符逆序输出):
Function ZF(S As String) As String
Dim n As Integer
n = Len(S)
If (1) Then
ZF =____(2)____
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
该程序采用的算法和划线处应该填入的内容分别为( )
Function ZF(S As String) As String
Dim n As Integer
n = Len(S)
If (1) Then
ZF =____(2)____
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
该程序采用的算法和划线处应该填入的内容分别为( )
A.解析 (1) n<=1 (2) s |
B.解析 (1) n>=1 (2) Mid(s,n,1) |
C.递归 (1) n>=1 (2) s |
D.递归 (1) n<=1 (2) Mid(s,n,1) |
有如下程序段:
Function f(a As Integer, b As Integer) As Integer
Dim k As Integer
k = a Mod b
If k = 0 Then
f = b
Else
f = f(b, a mod b)
End If
End Function
Private Sub Command1_Click()
Dim i As Integer, j As Integer
i = Val(Text1.Text)
j = Val(Text2.Text)
Text3.Text = Str(i * j / f(i, j))
End Sub
该程序运行之后,在text1与text2分别输入25 与15,点击command1后在text3上显示的内容为( )
Function f(a As Integer, b As Integer) As Integer
Dim k As Integer
k = a Mod b
If k = 0 Then
f = b
Else
f = f(b, a mod b)
End If
End Function
Private Sub Command1_Click()
Dim i As Integer, j As Integer
i = Val(Text1.Text)
j = Val(Text2.Text)
Text3.Text = Str(i * j / f(i, j))
End Sub
该程序运行之后,在text1与text2分别输入25 与15,点击command1后在text3上显示的内容为( )
A.5 | B.30 | C.75 | D.125 |
已知斐波那契数列前8项是1,1,2,3,5,8,13,21,设计如下VB程序求其第n 项的值:
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)
该程序用到了下列哪一个算法( )
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)
该程序用到了下列哪一个算法( )
A.枚举算法 | B.递归算法 | C.排序算法 | D.查找算法 |