2 回答
TA贡献1868条经验 获得超4个赞
这是解决方案:
HTML:
<div class="column1">
<div class="input">
<button onclick="problem_09()"> Run the program </button>
</div>
<strong><div id="output"> </div></strong>
</div>
记者:
function problem_09() {
var outputObj = document.getElementById("output");
var a = parseInt(prompt("Please enter a number: ", ""));
var digit = "";
outputObj.innerHTML = ""
while(a > 0){
let num = a%10
a = Math.floor(a/10)
digit += "<p>"+num+"</p>"
}
outputObj.innerHTML = digit + "<br><br>" + "program ended";
document.getElementsByTagName("button")[0].setAttribute("disabled","true");
}
TA贡献1830条经验 获得超9个赞
从数学上讲,取余数模 10 除以 10。在简单的代码中,
num = some number
while (num>0):
print(num%10)
num = num/10
添加回答
举报