麻烦老师检查,看下是否需要优化
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src=""></script>
</head>
<body>
<script>
for (let i = 100; i < 1000; i++) {
let one = String(i).charAt(0);
let two = String(i).charAt(1);
let three = String(i).charAt(2);
if (one ** 3 + two ** 3 + three ** 3 === i) {
document.write("水仙花数:" + i, "<br>")
}
}
</script>
</body>
</html>0
收起
正在回答
1回答
你好,代码实现结果没有问题,写的也很简洁,不需要优化了,真棒!
祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星