Private Sub Command1_Click() '水仙花数定义:"水仙花数"是指一个三位数,其中各位数字的立方和等于该数本身 For i = 100 To 999 a = Int(i / 100) b = Int((i - 100 * a) / 10) c = i - Int(i / 10) * 10 If i = a ^ 3 + b ^ 3 + c ^ 3 Then Print i End If Next i End Sub Private Sub Command1_Click() For n = 100 To 999 s = 0 a = n Do While a <> 0 b = a Mod 10 s = s + b * b * b a = a\ 10 Loop If s = n Then Print n Next n End Sub
初级设计师
by: 海大软件1102班 发表于:2012-09-26 11:08:45 顶(0) | 踩(0) 回复
屌爆了!
回复评论