求1~1000之间的“水仙花数”。(注:“水仙花数”是一个三位数,其各位数的立方和等于该数本身。)
例如:153=1×1×1+5×5×5+3×3×3
代码如何写啊 谢谢高手指教 急!!!

解决方案 »

  1.   

    Sub bb()
    For i = 0 To 10000
    aaa i
    Next
    End SubSub aaa(intI)
        Dim i, temp
        For i = 1 To Len(intI)
    temp = temp + CInt(Mid(intI, i, 1)) * CInt(Mid(intI, i, 1)) * CInt(Mid(intI, i, 1))
        Next
        If CInt(intI) = CInt(temp) Then Debug.Print intI
    End Sub 0 
     1 
     153 
     370 
     371 
     407 
      

  2.   

    作业题吧~~
    dim a as integer , b as integer ,c as integer
    for a=0 to 9
      for b=0 to 9
        for c=0 to 9
          if a*100+b*10+c=a^3+b^3+c^3 then debug.print cstr(a*100+b*10+c)
        next
      next
    next