VB:用调用函数的方法找出所有三位数的水仙花数.

VB:用调用函数的方法找出所有三位数的水仙花数.
这是我写的代码:
Private Sub Command1_Click()
Dim a(101,999) As Integer
For a = 101 To 999 Step 1
If isnum = True Then Print a;
Next
End If
End Sub
Private Function isnum(n As Integer) As Boolean
a As Integer,b As Integer,c As Integer
a = n 100
b = n 10 Mod 10
c = n Mod 10
If n = a ^ 3 + b ^ 3 + c ^ 3 Then
isnum = True
Else
isnum = False
End If
End Function
运行时说我类型不匹配.
哪个类型啊?
帮我解决掉的加分.
雪中草原 1年前 已收到1个回答 举报

bjdgj 幼苗

共回答了17个问题采纳率:82.4% 举报

Private Sub Command1_Click()
Dim a As Integer
For a = 101 To 999 Step 1
If isnum(a) = True Then Print a;
Next
End Sub
Private Function isnum(n As Integer) As Boolean
Dim a As Integer, b As Integer, c As Integer
a = n 100
b = (n - a * 100) 10
c = n - a * 100 - b * 10
If n = a ^ 3 + b ^ 3 + c ^ 3 Then
isnum = True
Else
isnum = False
End If
End Function

1年前

3
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.733 s. - webmaster@yulucn.com