笔记
justwebm
Keep your chin up, someday there will be happiness again.
展开
-
点击页面button按钮,点击哪个按钮显示第几个
<body> <button>click me</button> <button>click me</button> <button>click me</button> <button>click me</button> <button>click me</button> <script>原创 2021-09-18 09:50:39 · 444 阅读 · 0 评论 -
js写简单开关灯案例
body部分<button class="btn">开关灯</button>js部分// 1、获取元素var btn=document. querySelector (".btn");var html=document. querySelector("html");// 2、注册事件var flag=0;btn. onclick=function(){ if(flag==0){ html. style. backgroundColor=原创 2021-02-11 18:35:32 · 446 阅读 · 0 评论 -
js实现简单随机点名
function getName(min,max){ return Math. floor(Math. random() *(max-min+1)) +min;}var arr=['张三','李四','王五','马六'];console. log (arr[getName(0,arr.length-1)]) ;原创 2021-02-02 19:25:02 · 534 阅读 · 0 评论 -
js猜数字,用户猜1~50之间的一个数字,且只有10次机会,猜对或超过次数,结束程序
function getRandom(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } var random = getRandom(1, 50); for (var i = 1; i <= 10; i++) { var num = prompt("请输入一个数字:"); if (num原创 2021-02-02 19:17:55 · 2293 阅读 · 3 评论 -
js的三种引用方法
1、利用script标签就行引用<script type="text/javascript">var str="你好js";document. write("使用js脚本语言循环输出hellow word!") ;for(var i=0;i<5;i++){ document. write("<h1>你好<h1>");}</scr...原创 2020-05-07 12:09:59 · 10652 阅读 · 0 评论 -
JAVA编写人机猜拳
创建个用户类(Person) public class Person { String name="用户"; int score; boolean is; int show; public int show(){ Scanner sc=new Scanner(System.in); do{ System.out.pr...原创 2020-05-02 19:17:50 · 296 阅读 · 0 评论 -
JAVA简单编写幸运抽奖
package cn. class. work;import java. util.Scanner;public class work{ public static void main(String[] args) { String answer ="y";//是否退出 String userName ="";//用户密码 S...原创 2020-05-02 18:59:04 · 2909 阅读 · 0 评论 -
JAVA使用switch和do-while写游戏平台(框架,内容忽略)
public static void maincgh原创 2020-05-02 19:08:38 · 275 阅读 · 0 评论 -
JAVA:某次程序大赛,S1班有4名学员参加,学员的成绩由用户输入;计算该班参赛学员的平均分
public static void main(String[]args){int[] scoreArray=new int[4];double avg=0. 00;double sum=0.00;Scanner sc=new Scanner(System.in);System. out. println(“请输入4位学员的成绩”);for(int i=0;i<...原创 2020-04-12 16:34:36 · 1395 阅读 · 0 评论 -
JAVA打印矩形和直角三角形
public static void main(String[]args) {System.out.println(“打印矩形”); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { System.out.print(" "); } System.out.println(); } Syste...原创 2020-04-12 16:13:22 · 252 阅读 · 0 评论 -
JAVA计算全班平均成绩
public static void main(String[] args) {Scanner sc=new Scanner(System. in) ;int [] score=new int[5]; //数组的定义,给数据大小int sum=0; //总成绩double avg; //平均成绩for(int i=0;i<score. length;i++) {Sys...原创 2020-03-19 11:49:14 · 4826 阅读 · 0 评论