编写程序:打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身.

1个回答

  • vb:

    Private Sub Form_Click()

    Dim a,b,c ,x As Integer

    For a = 0 To 9

    For b = 0 To 9

    For c = 1 To 9

    x=100 * c + 10 * b + a

    If a ^ 3 + b ^ 3 + c ^ 3 = a + 10 * b + 100 * c Then print x;

    Next c

    Next b

    Next a

    C语言的"水仙花数"代码

    main(){

    int i,j,k;

    for(i=1;i