VB穷举法找水仙花数,最好能把所有代码发出来
答案:1 悬赏:50
解决时间 2021-10-15 19:13
- 提问者网友:树红树绿
- 2021-10-15 12:42
VB穷举法找水仙花数,最好能把所有代码发出来
最佳答案
- 二级知识专家网友:深街酒徒
- 2021-10-15 13:36
private sub command1_click(0 '产生
dim i,j,a as integer,b as boolean
randomize
for i=1 to 100
do
a=int(rnd*900)+100
b=false
for j=0 to list1.listcount-1
if a=val(list1.list(j) then b=true:exit for
next
loop while b
list1.additem a
next
end sub
private sub command2_click() '筛选
dim i as integer
for i=0 to list1.listcount-1
if isnum(val(i)) then list2.additem i
next
end sub
private sub command3_click()
unload me
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
dim i,j,a as integer,b as boolean
randomize
for i=1 to 100
do
a=int(rnd*900)+100
b=false
for j=0 to list1.listcount-1
if a=val(list1.list(j) then b=true:exit for
next
loop while b
list1.additem a
next
end sub
private sub command2_click() '筛选
dim i as integer
for i=0 to list1.listcount-1
if isnum(val(i)) then list2.additem i
next
end sub
private sub command3_click()
unload me
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
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯