#程序 1
def eat_peach(day):
s=1
for i in range(9,day-1,-1):
s=(s+1)*2
return s
print(eat_peach(1))
#程序 2
if day==10:
return 1
else:
return (eat_peach(day+1)+1)*2
下列说法不正确的是( )
def up(n):
if n<2:
return up(n-1)+up(n-2)
n=int(input("请输入楼梯台阶数:"))
way=up(n)
print(way)
程序运行后,输入楼梯台阶数有6个,程序输出的结果是( )
Private Sub Commandl_Click()
Text1.Text = f(3)
End Sub
Function f(x As Integer)As String
If x = 1 Then f= 1 Else f = f(x-1)+ 2
End Function
运行程序并点击按钮Command1后,文本框Text1中显示的内容是( )
Private Sub Command1 Click()
Label2 Caption = trans(Val(Text1. Text),Val(Text2. Text))
Function trans(n As Integer, k As Integer) As String
If n< >0 Then
r = n Mod k
trans = trans(n\ k, k)+Str(r)
Else trans = 0
End If
End function
程序运行时,在文本框Text1和Text2中分别输入11和3,则Label2中的输出结果是( )
n=int(input())
f0,f1,f2=1,0,1
for i in range(3,n+1):
▲
f0,f1,f2= f1,f2,f3
print("爬n级台阶的方案数为",f3)
则划线处的代码为。该段代码使用了 (填:递归或迭代)算法。
def f(n):
if n == 5:
return ___①___
return _____②____
print(___③___)
def fibs(n):
if n==1 or n==2:
return ____①____
return _____②_____
m=int(input("请输入一个整数:"))
for i in range(1,m+1):
print(___③___ ,end=",")
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)的值为( )