vb题,编程显示100-500之间的所有水仙花数之和
1个回答
展开全部
程序代码如下:
Private Sub Command1_Click()
Dim i As Integer, a As Integer, b As Integer, c As Integer, s As Integer
For i = 100 To 500
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If a * a * a + b * b * b + c * c * c = i Then s = s + i
Next i
MsgBox "100-500之间的所有水仙花数之和=" & s
End Sub
Private Sub Command1_Click()
Dim i As Integer, a As Integer, b As Integer, c As Integer, s As Integer
For i = 100 To 500
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If a * a * a + b * b * b + c * c * c = i Then s = s + i
Next i
MsgBox "100-500之间的所有水仙花数之和=" & s
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询