题型:综合题 题类:模拟题 难易度:普通
浙江省名校信息技术仿真训练卷(三)
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Function f(x As Double)As Double
Dim Y As Double
y=x^3-4*x^2+x+5: ‘(1)
End Function
Private Sub Command1_Click()
Dim a As Double,b As Double,m As Double,x As Double
a=Val(Text1.Text):b=Val(Text2.Text)
If f(a)*f(b)<0 And a<b Then
Do While a<=b
m=(a+b)/2
If Abs(f(m))<0.00001 Then Exit Do
If <0 Then ‘(2)
b=m
Else
a=m
EndIf
Loop
x=Format(m,“0.00000”) ‘Format函数用于定义输出的小数位数
List1.AddItem"["&Text1.Text&","&Text2.Text&"]" & "解为:"&x
Else
List1.AddItem"["&a&","&b&"]" & "重新输入区间"
EndIf
End Sub
def fun(k): if k==1 : return "1" elifk%2==0: return fun(k- 1)+str(k%2) else: returnstr(k%2)+fun(k- 1) |
执行语句 s=fun(5) ,则 s 的值为( )
试题篮