一个三位数,若它的每个数字(即百位、十位、个位)的立方和等于该数,则该数称为水仙花数,显示水仙花数的程序是:
A: for i in range(1,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
B: for i in range(100,101): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
C: i=100 while i<=999: x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i) i++
D: for i in range(100,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
A: for i in range(1,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
B: for i in range(100,101): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
C: i=100 while i<=999: x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i) i++
D: for i in range(100,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i)
举一反三
- 下列选项中,能找出三位数中,所有个位数字是9并且是3的倍数的数的代码是( )。 A: for i in range(100,1000): if i%10=9 and i%3=0: print(i,end=' ') B: for i in range(100,1000): if i//10==9 and i//3==0: print(i,end=' ') C: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ') D: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ')
- 下面程序输出结果是x, y, z = 10, 0, 0def f(x): y = 0 global z for i in range(x): y += i z += i return y, zx = f(x)print(x, y, z) A: (45, 45) 45 45 B: (0, 45) 0 45 C: (45, 45) 0 45 D: 10 0 45
- 给以下程序填空,能输出{0:['python',123],1:['java',456],2:['c',789]}结果的选项是______。 x=("python","java","c") y=[123,456,789] z={} foriinrange(len(x)): ___________ print(z) A: z[i]=list(zip(x,y)) B: z[i]=x[i],y[i] C: z[i]=[x[i],y[i]] D: z[i]=x,y
- { 以下函数的功能是:求x的y次方,[ ]应填: double fun( double x, int y) { int i; double z; for(i=1, z=x;[ ] ); return z; A: i<;y;z*=x,i++ B: i<;=y;z*=x,i++ C: i<;y;x*=x,i++ D: i<;=y;x*=x,i++ }
- 下面程序的功能是求算式xyz+yzz=532中x,y,z的值(其中xyz和yzz分别表示一个三位数),请选择填空。#includemain(){intx,y,z,i,result=532;for(x=1;x<10;x++)for(y=1;y<10;y++)for(();z<10;z++){i=100*x+10*y+z+100*y+10*z+z;}} A: z=x B: z=1 C: z=0 D: z=y