用vb做,求全过程
答案:3 悬赏:50 手机版
解决时间 2021-03-04 23:19
- 提问者网友:遮云壑
- 2021-03-04 05:49
用vb做,求全过程
最佳答案
- 五星知识达人网友:逐風
- 2021-03-04 06:42
循环一下不就可以了?
For i = 100 To 1000
Dim s()
If (i = Mid(i, 1, 1) ^ 3 + Mid(i, 2, 1) ^ 3 + Mid(i, 3, 1) ^ 3) Then
Debug.Print "自恋数:" & i
End If
Next
For i = 100 To 1000
Dim s()
If (i = Mid(i, 1, 1) ^ 3 + Mid(i, 2, 1) ^ 3 + Mid(i, 3, 1) ^ 3) Then
Debug.Print "自恋数:" & i
End If
Next
全部回答
- 1楼网友:旧脸谱
- 2021-03-04 08:11
Private Sub Command1_Click()
Dim i As Integer
For i = 100 To 1000
Dim s()
If (i = Mid(i, 1, 1) ^ 3 + Mid(i, 2, 1) ^ 3 + Mid(i, 3, 1) ^ 3) Then
Print "自恋数:" & i
End If
Next
End Sub
求出153·370·371·407
Dim i As Integer
For i = 100 To 1000
Dim s()
If (i = Mid(i, 1, 1) ^ 3 + Mid(i, 2, 1) ^ 3 + Mid(i, 3, 1) ^ 3) Then
Print "自恋数:" & i
End If
Next
End Sub
求出153·370·371·407
- 2楼网友:雾月
- 2021-03-04 06:55
Private Sub Form_Load()
Dim i As Integer, n As Integer, j As Integer
Dim sum As Long
For i = 0 To 1000
sum = 0
n = Len(Str(i)) - 1 '获得数字的位数
For j = 1 To n
sum = sum + Int(Val(Mid(Str(i), j + 1, 1))) ^ 3
Next
If sum = i Then MsgBox sum
Next
End Sub
Dim i As Integer, n As Integer, j As Integer
Dim sum As Long
For i = 0 To 1000
sum = 0
n = Len(Str(i)) - 1 '获得数字的位数
For j = 1 To n
sum = sum + Int(Val(Mid(Str(i), j + 1, 1))) ^ 3
Next
If sum = i Then MsgBox sum
Next
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯