摘要: <script> var m = parseInt(prompt("请输入一个数")); function box(m) { var a = 0; while (m) { //循环m; a += m % 10; //计和,每次的余数相加; m = parseInt(m / 10); //取整,直到为 阅读全文
posted @ 2018-09-27 14:42 指尖下的幽魂 阅读(3069) 评论(0) 推荐(0) 编辑
摘要: <script> var li = document.getElementsByTagName("li"); //就相当于把li标签赋值给这个li变量; for (i = 0; i < li.length; i++) { // li.length是li的长度0-li.length-1; if (i 阅读全文
posted @ 2018-09-27 14:31 指尖下的幽魂 阅读(876) 评论(0) 推荐(0) 编辑
摘要: <script> function box(num) { for (i = 2; i < num; i++) { if (num % i == 0) { return false; } } return true; } //以上是判断一个数是否为函数,是返回true; function fac(m, 阅读全文
posted @ 2018-09-26 14:40 指尖下的幽魂 阅读(2878) 评论(0) 推荐(0) 编辑
摘要: <script> function box(num) { for (i = 2; i < num; i++) { ///素数是除了1和他本身,就没有其他能被整数的,所以,知道有就返回false,这个数就不是素数 if (num % i == 0) { return false; } } return 阅读全文
posted @ 2018-09-26 14:17 指尖下的幽魂 阅读(3637) 评论(0) 推荐(0) 编辑
摘要: <script> for (i = 1; i <= 9; i++) { //控制为9行 for (j = 1; j <= i; j++) { document.write(j + "*" + i + "=" + j * i + "&nbsp;&nbsp;&nbsp;"); //每次循环,i不变,j在 阅读全文
posted @ 2018-09-25 15:58 指尖下的幽魂 阅读(287) 评论(0) 推荐(0) 编辑
摘要: <script> var num = parseInt(prompt("请输入一个正整数")); var count = 0; //计数器 while (true) { //循环表达式为true,永远循环 if (num > 0) { break; //除非符合这个条件,break,退出此循环 } 阅读全文
posted @ 2018-09-25 15:48 指尖下的幽魂 阅读(5922) 评论(1) 推荐(0) 编辑
摘要: <script> var num = parseInt(prompt("请输入一个人整数")); var cheng = 1; for (i = 1; i <= num; i++) { cheng = cheng * i; } alert("这个数的阶乘为" + cheng); </script> 阅读全文
posted @ 2018-09-25 15:40 指尖下的幽魂 阅读(162) 评论(0) 推荐(0) 编辑
摘要: .box { /* 大盒子宽高已知 */ width: 400px; height: 400px; background: #Ccc; text-align: center; } .box1 { /* 小盒子宽高未知 */ width: 200px; height: 100px; backgroun 阅读全文
posted @ 2018-09-25 15:38 指尖下的幽魂 阅读(212) 评论(0) 推荐(0) 编辑
摘要: .box {/* 大盒子高宽未知 */ width: 400px; height: 400px; background: #Ccc; position: relative; } .box1 {/* 小盒子高宽已知 */ width: 100px; height: 100px; background: 阅读全文
posted @ 2018-09-25 15:33 指尖下的幽魂 阅读(189) 评论(0) 推荐(0) 编辑
摘要: .box {/* 大盒子 */ width: 400px; height: 400px; background: #Ccc; display: flex; justify-content: center;//水平居中 align-items: center;//垂直居中 } .box1 {/* 小盒 阅读全文
posted @ 2018-09-25 15:30 指尖下的幽魂 阅读(193) 评论(0) 推荐(0) 编辑