• 四则运算


    <%@ page language="java" contentType="text/html; charset=utf8"
        pageEncoding="utf8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>四则运算</title>
    <body>
    <table  width="500" border="0">
    <tr>
      <td  align="center" colspan="2" style="background-color:#FFA500;">
            <head>四则运算</head>
       </td>
    </tr>
    <tr>
    <td>
      <form action="request.jsp" mehod="post">
    
       请输入题目数量:<input id="demo" type="test" name="num"><br />
    
    </form>
    </td>
    
    </tr>
    
    </table>
    
    <script >
     function myFunction(){
         var x=document.getElementByld("demo").value;
         if(x==""||lisNaN(x)){
             alert("输入错误,请重新输入");
         }
     }
    </script>
    
    </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=utf8"
        pageEncoding="utf8"%>
        <%@ page import="java.util.*" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>获取参数</title>
    </head>
    <body  background="C:\Users\admin\Pictures\Saved Pictures\1.jpg" style="color:white">
      <form action="judge.jsp" method="post" >
      <p >
       <%
         int num=Integer.parseInt(request.getParameter("num"));
         int[] result=new int[num];
         int[] re=new int[num];
         for(int i=0;i<num;i++){
             Random random=new Random();
             int fuhao=Math.abs(random.nextInt()%4);
             int a=Math.abs(random.nextInt()%(num-1))+1;
             int b=Math.abs(random.nextInt()%(num-1))+1;
              if(fuhao==0){
                  result[i]=a+b;
                  out.println(a+"+"+b+"=");
              }
              if(fuhao==1){
                  if(a>=b){
                      result[i]=a-b;
                      out.println(a+"-"+b+"=");
                  }
                  else{
                      result[i]=b-a;
                      out.println(b+"-"+a+"=");
                  }
              }
              if(fuhao==2){
                  result[i]=a*b;
                  out.println(a+"*"+b+"=");
              }
              if(fuhao==3){
                  if(a%b!=0) {i--;continue;}
                  if(b==0) {i--;continue;}
                  else{
                  result[i]=a/b;
                  out.println(a+"/"+b+"=");
                  }
              }
            %>
              <input type="text" name=<%=i%>><br>
              </p>
              <%
         }
        
             session.setAttribute("v1",re);     session.setAttribute("v2",result);
             session.setAttribute("v3",num);
             %>
              <input type="submit" name="submit" value="submit" >
      </form>
    </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=GBK"
        pageEncoding="GBK"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>结果</title>
    </head>
    <body>
      <%
        
        int[] k=(int [])session.getAttribute("v2");
        int n=(Integer)session.getAttribute("v3");
        int []s=new int [n];
        for(int i=0;i<n;i++){
            s[i]=Integer.parseInt(request.getParameter(i+""));
        }
        int right=0;
        for(int i=0;i<n;i++){
            out.println(i+1+":");
            if(s[i]==k[i]){
                out.print("right");
                right++;
            }
            else out.print("false");
            out.print("<br>");
        }
        %>
      <input type="button" value="关闭" onClick="window.close();">  
    </body>
    </html>
  • 相关阅读:
    URL和DNS解析
    web工作方式,浏览网页,打开浏览器,输入网址按下回车键,然后会显示出内容,这个过程是怎样的呢?
    PHP根据数组的值分组
    EditPlus注册码在线生成,强大
    php获取内容中第一张图片地址
    PHP函数ip2long转换IP时数值太大产生负数的解决办法
    js Uncaught SyntaxError: Unexpected token错误
    虚拟机centos6.5 --VirtualBox设置全屏
    虚拟机centos6.5 --设置静态ip
    centos之开放80端口
  • 原文地址:https://www.cnblogs.com/wangzhaojun1670/p/11815733.html
Copyright © 2020-2023  润新知