vb三重循环是怎样的用三重循环显示所有三位数的的水仙花数
Dim i%, j%, m% s = i * 100 + j * 10 * m ‘一定=0 Do While s > 0 ‘一定不成立 ‘”水仙花数” Private Sub Form_Click() Dim a, b, c As Integer ‘a(个)b(十)c(百) For a = 0 To 9 For b = 0 To 9 For c = 1 To 9 If a ^ 3 + b ^ 3 + c ^ 3 = a + 10 * b + 100 * c Then MsgBox 100 * c + 10 * b + a End If Next c Next b Next a End Sub ”””””””””””’ Private Sub Form_Click() Dim i%, j%, m%, n% 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 Print n; “=”; i; “^3+”; j; “^3+”; m; “^3” End If Next n End Sub
本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:dandanxi6@qq.com