• Web四则混合运算


    一、代码1:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!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>
    </head>
    <body>
    <%
    JspWriter mout=pageContext.getOut();
    String zh = request.getParameter("shuliang");
    String zhh = request.getParameter("choose");
    int x=Integer.parseInt(zh);
    int y=Integer.parseInt(zhh);
    int m,n,j;
    char []ch=new char[4];
    ch[0]='+';
    ch[1]='-';
    ch[2]='*';
    ch[3]='/';
    if(y==1)
    {
    for(int ii=1;ii<=x;ii++)
    {
    mout.print("30道题目");
    mout.print("<br>");
    String []A=new String[30];
    for(int i=0;i<30;i++)
    {
    m=(int)(Math.random()*10+1);
    n=(int)(Math.random()*10+1);
    j=(int)(Math.random()*4+1);
    A[i]=m+" "+ch[j-1]+" "+n+"=";
    for(int k=i+1;k<30;k++)
    {
    if(A[i].equals(A[k]))
    {
    m=(int)(Math.random()*10+1);
    n=(int)(Math.random()*10+1);
    j=(int)(Math.random()*4+1);
    A[k]=m+" "+ch[j-1]+" "+n+"=";
    k--;
    }
    }
    mout.print((i+1)+". "+A[i]);
    mout.print("<br>");
    }
    mout.print("-"+ii+"-");
    mout.print("<br><br><br>");
    }
    }
    if(y==2)
    {
    for(int ii=1;ii<=x;ii++)
    {
    int a,b,c,d;
    String aa,bb;
    mout.print("30道题目");
    mout.print("<br>");
    String []B=new String[30];
    for(int i=0;i<30;i++)
    {
    a=(int)(Math.random()*100+1);
    b=(int)(Math.random()*100+1);
    if(a>b)
    aa=b+"/"+a;
    else if(a<b)
    aa=a+"/"+b;
    else
    aa="1";
    c=(int)(Math.random()*100+1);
    d=(int)(Math.random()*100+1);
    if(c>d)
    bb=d+"/"+c;
    else if(c<d)
    bb=c+"/"+d;
    else
    bb="1";
    j=(int)(Math.random()*4+1);
    B[i]=aa+" "+ch[j-1]+" "+bb+"=";
    for(int k=i+1;k<30;k++)
    {
    if(B[i].equals(B[k]))
    {
    m=(int)(Math.random()*10+1);
    n=(int)(Math.random()*10+1);
    j=(int)(Math.random()*4+1);
    B[k]=aa+" "+ch[j-1]+" "+bb+"=";
    k--;
    }
    }
    mout.print((i+1)+". "+B[i]);
    mout.print("<br>");
    }
    mout.print("-"+ii+"-");
    mout.print("<br><br><br>");
    }
    }
    %>
    </body>
    </html>

    代码2:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!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=ISO-8859-1">
    <title>四则运算</title>
    </head>
    <body>
    <h1>四则运算</h1>
    <form action="yunsuan.jsp" method="post">
    出题页数:<input type="text" name = "shuliang"><br>
    <h1>题目样式:1.整数运算2.真分数运算</h1>
    题目样式:<input type="text" name="choose"><br>
    <input type="submit" value="提交">
    </form>
    </body>
    </html>

    二、截图1:

         截图2:

  • 相关阅读:
    506Relative Ranks(LeetCode)
    计算二进制中1的个数
    vector<vector<int>> 简单知识介绍
    167. Two Sum II
    561. Array Partition I(LeetCode)
    sizeof 用法部分总结
    530. Minimum Absolute Difference in BST(LeetCode)
    JS计算两个日期之间的天数
    路演会上会登记结论的委员信息页面
    eclipse安装SVN插件
  • 原文地址:https://www.cnblogs.com/zyx111/p/6492275.html
Copyright © 2020-2023  润新知