• 2022-06-12
    一个三位数,若它的每个数字(即百位、十位、个位)的立方和等于该数,则该数称为水仙花数,显示水仙花数的程序是:
    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)
  • 举一反三