zoukankan      html  css  js  c++  java
  • 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:

  • 相关阅读:
    P4396 [AHOI2013]作业 分块+莫队
    B1965 [Ahoi2005]SHUFFLE 洗牌 数论
    B1970 [Ahoi2005]Code 矿藏编码 暴力模拟
    B1968 [Ahoi2005]COMMON 约数研究 数论
    B1237 [SCOI2008]配对 贪心 + dp
    B1108 [POI2007]天然气管道Gaz 贪心
    B1734 [Usaco2005 feb]Aggressive cows 愤怒的牛 二分答案
    B1012 [JSOI2008]最大数maxnumber 分块||RMQ
    HAOI2007 反素数
    NOIP2009 Hankson的趣味题
  • 原文地址:https://www.cnblogs.com/zyx111/p/6492275.html
Copyright © 2011-2022 走看看