Private Sub Form_Click()
Dim i As Integer
Dim s As Integer
s = 1
For i = 1 To 9
s = (s + 1) * 2
Next i
Print "s="; s
End Sub
是1534个 循环9次。因为第十天已经剩下1个 就没再吃了 楼上那位 han4422951 - 都司 七级 初始值S为1 你还用除2 真服你了。~
Private Sub Form_Click()
Dim i As Integer
Dim s As Integer
s = 1 '第十天的个数
For i = 1 To 9 '另外9天
s = (s + 1) * 2 '前一天的个数为当天个数加1的2倍
Next i
Print "s="; s
End Sub
'结果:1534
Private Sub Form_Click()
Dim i As Integer
Dim s As Integer
s= 1
For i=1 to 10
s= (s + 1) / 2
Next i
Print "s="; s
End Sub
Dim a%, s%, i%
a = 1 : s = 0
For i = 1 To 9
s = a * 2 + 2
a = s
Next
Print "s="; s
你拿笔自己演算一下就会知道,每一天的桃子数总是第二天的两倍多两个,第四行代码就是根据每天的桃子数算出前一天的桃子数,然后再根据前一天的桃子数算出再前一天的桃子数,这个循环不能循环十次,因为循环了九次后已经是最初一天的桃子数了!最后的答案是1534
这不是数学题吗?
dim Taozi as long
taozi=1
for i=1 to 10
taozi=taozi+1
taozi=taozi*2
next i
msgbox "桃子总数: " & trim(taozi)
private sub form_click
dim n%,i%
x=1
print"第10天的桃子数为:1个"
for i= 9 to 1 step-1
x=(x+1)*2
print"第";i;"天的桃子数为:";x;"个"
next i
end sub