编写一个程序,求 100~999 之间的所有水仙花数
编写一个程序,求 100~999 之间的所有水仙花数。求解答,以下代码是什么意思?while循环里面就看不懂了。
for i in range(100, 1000):
sum = 0
temp = i
while temp:
sum = sum + (temp%10) ** 3
temp //= 10 # 注意这里要使用地板除哦~
if sum == i:
print(i)
谢谢! https://fishc.com.cn/forum.php?mod=viewthread&tid=159491&highlight=%CB%AE%CF%C9%BB%A8%CA%FD 你可以在论坛左上角搜索水仙花数 https://fishc.com.cn/forum.php?mod=viewthread&tid=160566 看这个 大佬笔记 给你整的明明白白
【Pyhon 009讲心得体会】【摸球和水仙花数 】
https://fishc.com.cn/thread-126088-1-1.html
(出处: 鱼C论坛)
页:
[1]