<!DOCTYPE html>
<html>
  <head>
	<meta charset="utf-8">
	<title>WebCat</title>
    <style>
    .xzan{
    width:25vw;
    height:7vh;
    text-align:center;
    font-size:10vw;
    }
    </style>
  </head>
  <body>	
	<h1 style="text-align:center;">石头,剪刀,布</h1>
    <div style="text-align:center;">
      <input type="button" class="xzan" value="剪刀" onclick="jqr(0)"/>
      <input type="button" class="xzan" value="石头" onclick="jqr(1)"/>
      <input type="button" class="xzan" value="布" onclick="jqr(2)"/>
    </div>
<script>
   const op = ["剪刀","石头","布"];
   function jqr(i){
    var star = Math.floor(Math.random() * op.length);
    var result;
    if(i==star){
        result = "平局";
    }else if ((i==0 && star==1) || (i==1 && star==2) || (i==2 && star==0)){
        result = "你输了";
    }else{
        result = "你赢了";
    }
    alert("机器人出的是" + op[star] + "," + result);
}
</script>
  </body>
</html
!DOCTYPE htmlhtml head	meta charset=utf-8 name=viewport content=width=device-width initial-scale=1 maximum-scale=1 user-scalable=no	titleWebCattitle style #v1 text-aligncenter; #v2

原文地址: https://www.cveoy.top/t/topic/fyHX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录