中易网

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

答案:6  悬赏:0  
解决时间 2021-01-11 02:30
  • 提问者网友:却不属于对方
  • 2021-01-10 18:47
急急急!求100到999之间所有的水仙花数
最佳答案
  • 二级知识专家网友:轻雾山林
  • 2021-01-10 19:34
你不要过程呀,那结果是:
水仙花数共有4个,分别为:153、370、371、407
全部回答
  • 1楼网友:鸠书
  • 2021-01-10 23:33
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
  • 2楼网友:鸽屿
  • 2021-01-10 23:12

#include
#include
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))
{
printf("水仙花数:%d ",i);
}
}
return 0;
}
  • 3楼网友:想偏头吻你
  • 2021-01-10 22:17
引用VB妮可的回答:
你不要过程呀,那结果是:
水仙花数共有4个,分别为:153、370、371、407clear
for i=1 to 9
for j=0 to 9
for k=0 to 9
n=i*100+j*10+k
if i^3+j^3+k^3=n
?n
endif
endfor
endfor
endfor
  • 4楼网友:底特律间谍
  • 2021-01-10 21:41
407
  • 5楼网友:毛毛
  • 2021-01-10 20:17
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
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息