百度试题 结果1 题目求1000以内的水仙花数.所谓水仙花数:$$ 1 5 3 = 1 3 + 5 3 + 3 3 $$ 相关知识点: 试题来源: 解析 水仙花数共有4个,分别为:153、370、371、407. 反馈 收藏
(循环控制 易)找出1000以内所有水仙花数。(各位数字的立方和等于该数本身,如1,153,407等数) 相关知识点: 试题来源: 解析 #include main() { int m,i,a,b,c; i=100; while(i<=999); { a=i/100; b=i/10%10; c=i%10; if((pow(a,3)+pow(b,3)+pow(c,3))==i) printf("%d\n",i);...
1~1000以内的水仙花数共有4个:153,370,371,407 1~1000以内的⽔仙花数共有4个:153,370,371,407 # n位数的每位数的n次⽅之和,等于这个数本⾝ print('1~1000的⽔仙花数为:')for i in range(1,1001):result=0 for j in str(i):#print(str(i))result+=pow(int(j),len(str(i)...
1. 水仙花数是指一个三位数,它的每个位上的数字的立方之和等于它本身。2. 例如:1^3 + 5^3 + 3^3 = 153,这是一个水仙花数。3. 在1到1000之间,共有4个三位的水仙花数。4. 它们分别是:153、370、371、407。
1~1000以内的 水仙花数共有4个:153,370,371,407 # n位数的 每位数的n次方之和,等于这个数本身 print('1~1000的水仙花数为:')foriinrange(1,1001): result=0forjinstr(i):#print(str(i))result+=pow(int(j),len(str(i)))#print(result)ifresult==i:print(i)...
System.out.println("1~1000以内的水仙花数:");for(inti=100;i<1000;i++){//a代表百位数inta = i/100;//b代表十位数intb = i/10%10;//c代表个位数intc = i%10;if(Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)==i){ System.out.print(i+"\t"); ...
153、370、371、407 153 = 1 * 1 * 1 + 5 * 5 * 5 + 3 * 3 * 3 370=3*3*3+7*7*7+0=27+343=370 371=3*3*3+7*7*7+1*1*1=371 407=4*4*4+0+7*7*7=64+343=407
水仙花数是指一个n位数(n)=3),它的每个位上的数字的n次幂之和等于它本身(例如:1^3+5^3+3^3=153) Private Sub Command1_Click() List1.clear Dim a As Integer For i = 1 To 1000 s = 0 l = Len(Str(i)) - 1 For j = 0 To l a = 1 s = s + a ^ 3 Next j If i = s...
水仙花数是指一个 n 位数 ( n>=3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153)三位的水仙花数共有4个,分别为:153、370、371、407
编程题: 输出 1000 以内的所有水仙花数。水仙花数是指一个三位数,数的本身等于各位数字立方之和,如 153=1^3+5^3+3^3 。 相关知识点: 试题来源: 解析 //求水仙花数 #include int main( ) { int n ,a,b,c; //n为某个三位数,a,b,c为它的三个数字 int m = 0; //用于计数 //用单重循环...