JS死循环
<script>
var num = parseInt(prompt("请输入一个正整数"));
var count = 0; //计数器
while (true) { //循环表达式为true,永远循环
if (num > 0) {
break; //除非符合这个条件,break,退出此循环
}
num = parseInt(prompt("请重新输入一个正整数"));
}
while (num) {
num = parseInt(num / 10);
count++;
}
alert("这个正整数为" + count + "位数");
</script>