vb,找出所有三位水仙花数,并将它们的最大与最小值显示在文本框t1和t2
3个回答
展开全部
Private Sub Command1_Click()
Dim k1 As Integer, k2 As Integer, k3 As Integer, x As Integer
t1.Text = ""
t2.Text = ""
For k1 = 1 To 9
For k2 = 0 To 9
For k3 = 0 To 9
x = Val(k1 & k2 & k3)
If k1 ^ 3 + k2 ^ 3 + k3 ^ 3 = x Then
Print x;
If t2.Text = "" Then
t2.Text = x
Else
t1.Text = x
End If
End If
Next k3
Next k2
Next k1
End Sub
展开全部
Private Sub Command1_Click()
Dim i, j, m, n, min, max As Integer
For n = 100 To 999
i = n \ 100
j = (n Mod 100) \ 10
m = n Mod 10
If i ^ 3 + j ^ 3 + m ^ 3 = n Then
If min = 0 Then
min = n
End If
If max < n Then max = n
End If
Next n
t1.Text = min
t2.Text = max
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我可以帮你搞,QQ8152456
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询