求一个VB高手帮我解答下问题,写2个程序,谢谢!
1个回答
2012-12-19
展开全部
Private Sub Command1_Click()'第(6)题
Cls
Randomize
Dim n As Integer, k As Integer
For i = 1 To 10
a = Int(Rnd * 90 + 10)
k = k + 1
If a Mod 2 = 0 Then
Print a, "***"
n = n + 1
If n = 4 Then Exit For
Else
Print a
End If
Next i
Print "共产生了"; k; "个数"
End Sub
'第(4)题
Private Sub Command1_Click()
Dim s As Integer, i As Integer, j As Integer, n As Integer
For i = 100 To 999
s = 0
For j = 1 To Len(Trim(Str(i)))
s = s + Val(Mid(Trim(Str(i)), j, 1)) ^ 3
Next j
If s = i Then
n = n + 1
Print "第"; n; "个水仙花数是 :"; i
End If
Next i
End Sub
Cls
Randomize
Dim n As Integer, k As Integer
For i = 1 To 10
a = Int(Rnd * 90 + 10)
k = k + 1
If a Mod 2 = 0 Then
Print a, "***"
n = n + 1
If n = 4 Then Exit For
Else
Print a
End If
Next i
Print "共产生了"; k; "个数"
End Sub
'第(4)题
Private Sub Command1_Click()
Dim s As Integer, i As Integer, j As Integer, n As Integer
For i = 100 To 999
s = 0
For j = 1 To Len(Trim(Str(i)))
s = s + Val(Mid(Trim(Str(i)), j, 1)) ^ 3
Next j
If s = i Then
n = n + 1
Print "第"; n; "个水仙花数是 :"; i
End If
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询