vb编程题,求大神指导,只会做前半段,在线等!
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
展开全部
Dim i As Long, j As Long '用来控制两层循环的变量
Dim he As Long '用来做累加
Dim s As String '控制输出的字符
Print "1000以内的完全数有:"
For i = 2 To 1000 '因为1肯定不是,所以从2开始,如果你们老师规定从1开始,也可以
s = i & "=" & "1"
he = 1
For j = 2 To i - 1
If i Mod j = 0 Then
s = s & "+" & j
he = he + j
End If
Next j
If he = i Then '说明这是个完全数
Print s
End If
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim N As Integer, I As Integer, S As String, H As Integer
For N = 3 To 1000
S = N & "=1"
H = 1
For I = 2 To N / 2
If (N Mod I) = 0 Then
S = S & "+" & I
H = H + I
End If
Next I
If H = N Then Print S
Next N
For N = 3 To 1000
S = N & "=1"
H = 1
For I = 2 To N / 2
If (N Mod I) = 0 Then
S = S & "+" & I
H = H + I
End If
Next I
If H = N Then Print S
Next N
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询