四大书院在哪:vb解决的几个问题

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 04:59:06
第三十六项的值
Private Sub Command1_Click()
Dim c As Integer
Dim a(1 To 36)

a(1) = 0
a(2) = 0
a(3) = 1

For c = 4 To 36
a(c) = a(c - 1) + a(c - 2) + a(c - 3)
Next c
Print a(36)
End Sub
*********************************************
同构数
Private Sub Command1_Click()
Dim i, p, count As Integer

count = 0
For i = 2 To 9
If (i ^ 2 - i) Mod 10 = 0 Then count = count + 1
If (i ^ 2 - i) Mod 10 = 0 Then Print i
Next i
For i = 10 To 99
If (i ^ 2 - i) Mod 100 = 0 Then count = count + 1
If (i ^ 2 - i) Mod 100 = 0 Then Print i
Next i
For i = 100 To 999
If (i ^ 2 - i) Mod 1000 = 0 Then count = count + 1
If (i ^ 2 - i) Mod 1000 = 0 Then Print i
Next i
Print "**********"
Print count
End Sub
*********************************************
因子
Private Sub Command1_Click()
Dim i, p, number, count As Integer
number = 0
For i = 1 To 100
count = 0
For p = 1 To i
If (i Mod p = 0) Then count = count + 1
Next p
If (i Mod count = 0) Then number = number + 1
If number = 10 Then Exit For
Next i
Print i
End Sub
*********************************************
猴子吃桃子
Private Sub Command1_Click()
Dim c As Integer
Dim a(1 To 10)

a(1) = 1
For c = 2 To 10
a(c) = (a(c - 1) + 1) * 2
Print a(c)
Next c
Print a(10)
End Sub
*********************************************
47题 前24项和
Private Sub Command1_Click()
Dim c As Integer
Dim sum As Single
Dim a(1 To 24)
Dim b(1 To 24)

sum = 0
a(1) = 2
b(1) = 1

For c = 2 To 24
a(c) = a(c - 1) + b(c - 1)
b(c) = a(c - 1)
sum = a(c) / b(c) + sum
Next c
Print sum + 2

1:334745777
2:
5
6
25
76
376
625
*******************
6

3:56

4:
4
10
22
46
94
190
382
766
1534
1534

5:
39.1324