索多玛120天无删版mp4:会VB请进~

来源:百度文库 编辑:高考问答 时间:2024/05/05 16:48:44
我知道这个问题可能蛮小白的````````````

但是```我真的就这么小白``- -

就是求水仙花数啦~

求数100到999中的数字I

是I的每位数的立方和为I

例如 153中 1^3+5^3+3^3=153

所以153就是水仙花数啦``````

谢谢大家~告诉我怎么编吧````呵呵~
Private Sub Command1_Click()

Dim i%, a$, b$, c$, d$, e%, f%, g%

For i = 100 To 999
a = Str(i)
b = Mid(a, 1, 1)
c = Mid(a, 2, 1)
d = Mid(a, 3, 1)
e = Val(b)
f = Val(c)
g = Val(d)
If e * e * e + f * f * f + g * g * g = i Then Print "水仙花数为"; i

Next i

End Sub

我这个为什么只出370呢?

那一种我也知道``````

但是老师要求一定要用这种啊~

SO````郁闷```````````

Private Sub Command1_Click()
Dim i As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
For i = 100 To 999

b = i \ 100
c = (i Mod 100) \ 10
d = i Mod 10

If b ^ 3 + c ^ 3 + d ^ 3 = i Then Print "水仙花数为"; i

End Sub
不要用那么多类型转换...容易出错.

for