我国人口13亿,按年增长0.2%计算,几年后超过15亿?用vb如何编写?

来源:百度知道 编辑:UC知道 时间:2024/05/29 19:18:49
用DO WHILE 之类的编写

Private Sub Command1_Click()
n=1
do while sum<15
n=n+1
sum=13*(1+0.002)^n
loop
print n & "年后超过15亿"
End Sub

Private Sub Command1_Click()
Dim n As Integer
Dim a As Single
For n = 1 To 99
If 13 * (1 + 0.002) ^ n > 15 Then
Print n
Exit For
End If
Next
End Sub

要72年

n=13
do while n<=15
n=n*1.002
i=i+1
loop
print i

2 年后是13.052052
3 年后是13.078156104
4 年后是13.104312416208
5 年后是13.1305210410404
6 年后是13.1567820831225
7 年后是13.1830956472887
8 年后是13.2094618385833
9 年后是13.2358807622605
10 年后是13.262352523785
11 年后是13.2888772288326
12 年后是13.3154549832902
13 年后是13.3420858932568
14 年后是13.3687700650433
15 年后是13.3955076051734
16 年后是13.4222986203838
17 年后是13.4491432176245
18 年后是13.4760415040598
19 年后是13.5029935870679
20 年后是13.529999574242
21 年后是13.5570595733