1000以内的所有阿姆特朗数和的平方根

2026-05-31

如果一个n位正整数等于其各位数字的n次方之和,则称该数为阿姆斯特朗数。 例如1^3 + 5^3 + 3^3 = 153 当n=3时,又称水仙花数,特指一种三位数,其各个数之立方和等于该数。 水仙花数共有4个,分别为:153、370、371、407。1000以内的所有阿姆特朗数153 370 371 407 和的平方根=±(153+370+371+407)=±根号1301≈36.069...

阅读更多

VB编程1-1000数字的代码

2026-05-31

所谓的水仙花数(梅花数)是指在三位整数(100到999之间)中,百位数、十位数、个位数的立方和等于它本身,如153=1^3+5^3+3^3。程序代码如下: Private Sub Command1_Click() Dim i As Integer, s As Integer Dim a As Integer, b As Integer, c As Integer Print "100到999所有水仙花数(也叫梅花数):" ; For i = 100 To 999 a = i \...

阅读更多

C语言求助:求1000以内的水仙花数

2026-05-30

#include<iostream>usingnamespacestd;voidmain(){intm=1,n=0,x=0;cout<<"1000以内的所有水仙花数数:"<<endl;;for(;m<=1000;m++){x=m/100;n+=x*x*x;x=m%100/10;n+=x*x*x;x=m%100%10;n+=x*x*x;if(n==m){cout<<m<<"\t";}n=0;}cout<<endl;}...

阅读更多