练习
This commit is contained in:
59
考试/原题/js/daziji.html
Normal file
59
考试/原题/js/daziji.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
// var str = "233333333333333333333"
|
||||
// var strnew=""
|
||||
// var i = 0
|
||||
// var typer=setInterval(()=>{
|
||||
// if(str[i]){
|
||||
// document.write(str[i])
|
||||
// i=i+1
|
||||
// }
|
||||
|
||||
// },1000)
|
||||
// if(i==str.length){
|
||||
// clearInterval(typer)
|
||||
// }
|
||||
// document.write(str[i])
|
||||
|
||||
|
||||
// 10
|
||||
//
|
||||
function mofa(n){
|
||||
let str=""
|
||||
if(typeof n=="number"){
|
||||
if(n>0&&n<=10){
|
||||
while(n>0){
|
||||
if(n%2){
|
||||
str="1"+str
|
||||
n=(n-1)/2
|
||||
}else{
|
||||
str="2"+str
|
||||
n=(n-2)/2
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.log("n必须小于10")
|
||||
}
|
||||
}else{
|
||||
console.log("请输入数字")
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
let mfb=mofa(10)
|
||||
console.log(mfb)
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user