自动生成一百以内加减法

现在一年级小学生需要练习大量的加减法。这是用html 写的一个小程序。希望对大家有所帮助。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>
  function start1(){
      var i;

          var a=Math.round(parseInt(Math.random()*100));
          var b=Math.round(parseInt(Math.random()*100));
          var c=Math.round(parseInt(Math.random()*2));//0-2  ≥0  <2   故只产生0 1
          alert(c);
          if(c==0)
             app.sign.value="+";
          else
             app.sign.value="-";
          app.num1.value=a;
          app.num2.value=b;


          }
  function judge(){
      if(app.sign.value=="+"){

          if(parseInt(app.num3.value)==parseInt(app.num1.value)+parseInt(app.num2.value)){
              alert("Correct");
          }
          else
              alert("Wrong");


      }
      else if(app.sign.value=="-"){
      if(parseInt(app.num3.value)==parseInt(app.num1.value)-parseInt(app.num2.value)){
          alert("Correct");
      }
      else
          alert("Wrong");

      }

      }
</script>
</head>
<body>
<form name="app">
<p>ADD&SUB</p>
<input type="button"   value=start onClick=start1()><br></br>
<input type="text"  name="num1" >
<input type="text"  name="sign" size="1">
<input type="text"  name="num2"> =
<input type="text"  name="num3" > <br></br>
<input type="button"   value=submmit onClick=judge()>
</form>

</body>
</html>

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值