急急急!求100到999之间所有的水仙花数

来源:百度知道 编辑:UC知道 时间:2024/05/31 11:20:38
请告诉我100到999之间所有的水仙花数
我不要程序的过程啊 只要结果

你不要过程呀,那结果是:
水仙花数共有4个,分别为:153、370、371、407

407

1.
for i=100 to 999
a=int(i/100)
c=i mod 10
b=i-a*100-c
if i=a*a*a+b*b*b+c*c*c then print i
next i
end

vb
Private Sub Command1_Click()
Dim s As Integer: Dim n As Integer
For s = 100 To 999
If (Val(Left(s, 1))) ^ 3 + (Val(Mid(s, 2, 1))) ^ 3 + (Val(Right(s, 1))) ^ 3 = Val(s) Then
Print s;
n = n + 1
If n Mod 8 = 0 Then Print
End If
Next s
Print
Print "共有水仙花数" & n & "个"
End Sub

#include <stdio.h>

#include <stdlib.h>

int is_daffodils(int n)

{

int nums=n;

int a,b,c;

int flag = 0;

a = n % 10;

n/=10;

b = n % 10;

n/=10;

c = n % 10;

if(nums == a*a*a+b*b*b+c*c*c)

{

flag = 1;

}

return flag;

}

int main()

{

for(int i =100;i<=999;i++)

{

if(is_daffodils(i))

{