vb 题目 拜托咯找出100到999之间的水仙花数,所谓水仙花数是指该数各位的立方和等于其本身的整数,例如:1^3 +

1个回答

  • Private Sub form_click()

    Dim a As Integer, b As Integer, c As Integer

    Dim i As Integer

    For i = 100 To 999

    a = Mid(i, 1, 1)

    b = Mid(i, 2, 1)

    c = Mid(i, 3, 1)

    If i = a ^ 3 + b ^ 3 + c ^ 3 Then Print i;

    Next i

    End Sub

    不用你说的那么复杂,一个循环就可以搞定了。

相关问题