程序填空
1.马克思曾经做过这样一道趣味数学题:有30个人在一家小饭店里用餐,其中有男人、女人和小孩,每个男人花了3先令,每个女人花了2先令,每个小孩花了1先令,共花去34先令。求小孩的人数。
Private Sub Command1_Click()
n = 0
For m = 1 To 28
For w = 1 To 28
s = m * 3 + w * 2 + c
If s = 34 Then Print c
Next w
Next m
End Sub
2.“水仙花数”是指这样的数,其各位数字的立方和等于该数本身,如: 153=13+53+3^3。求100至999的范围内所有奇数中的水仙花数之和。
Private Sub Form_Click()
Dim i%, a%, b%, c%, sum%
FontSize = 14: FontBold = True
sum = 0
I = 100
Do
a = I \ 100
b = I \ 10 Mod 10
c = I Mod 10
Then
sum = sum + I
End If
I = I + 1
Loop While I <= 999
Print sum
End Sub
3.编程求1-99的平方和并输出结果。(328350)
Private Sub Form_Click()
Dim i As Integer, s As Single
For i = 1 To 99
Next i
FontSize = 12
FontBold = True
Print s
End Sub
问题解决啦