zoukankan      html  css  js  c++  java
  • 简单web四则运算出题

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
     7 <title>自动出题</title>
     8 </head>
     9 
    10 <body >
    11     <form action="chuti.jsp" method="post">
    12     <center>
    13     <h2>自动出题</h2>
    14     <h3><font>出题类型:<input type="radio" name="type" value="zhengshu">整数
    15                 <input type="radio" name="type" value="zhenfenshu">真分数
    16                 <input type="radio" name="type" value="douyou">都有</font></h3>
    17     <h3><font>出题数:<input type="text" name ="chutishu"  ></font><br></h3>
    18     </center>
    19     </form>
    20     
    21      
    22     
    23 </body>
    24 </html>
     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
     7 <title>自动出题</title>
     8 </head>
     9     <%!
    10     public String putong(){
    11         char [] a=new char[4];
    12         a[0]='+';a[1]='-';a[2]='*';a[3]='/';
    13         int num1=(int)(Math.random()*10+1);
    14         int num2=(int)(Math.random()*10+1);
    15         int num=(int)(Math.random()*4+0);
    16         String s=num1+" "+a[num]+" "+num2+" =?";
    17         return s;
    18     }
    19     %>
    20     <%!
    21     public String zhenfenshu(){
    22         char [] a=new char[4];String m,n="";
    23         a[0]='+';a[1]='-';a[2]='*';a[3]='/';
    24         int num1=(int)(Math.random()*10+1);
    25         int num2=(int)(Math.random()*10+1);
    26         for(;num1==num2;num1=(int)(Math.random()*10+1),num2=(int)(Math.random()*10+1)){}
    27             if(num1<num2){
    28                 m=num1+"/"+num2;
    29             }
    30             else
    31                 m=num2+"/"+num1;
    32             
    33         for(num1=(int)(Math.random()*10+1),num2=(int)(Math.random()*10+1);num1==num2;num1=(int)(Math.random()*10+1),num2=(int)(Math.random()*10+1)){}    
    34         
    35             if(num1<num2){
    36                 n=num1+"/"+num2;
    37             }
    38             else 
    39                 n=num2+"/"+num1;
    40             
    41         int num=(int)(Math.random()*4+0);
    42         String s=m+" "+a[num]+" "+n+" =?";
    43         
    44         return s;
    45     }%>
    46     
    47 <body>
    48     <%
    49     String type = (String)request.getParameter("type");
    50     int chutishu=Integer.parseInt(request.getParameter("chutishu"));
    51     int j=0;
    52      String []a=new String [chutishu];
    53     
    54     for(j=0;j<chutishu;j++){
    55         if(type.equals("zhengshu"))
    56             a[j]=putong();
    57         else if(type.equals("zhenfenshu"))
    58             a[j]=zhenfenshu();
    59         else if(type.equals("douyou")){
    60             int m=(int)(Math.random()*2+1);
    61             if(m==1)
    62                 a[j]=putong();
    63             else if(m==2)
    64                 a[j]=zhenfenshu();
    65         }
    66         
    67         for(int k=0;k<j;k++){
    68             if(a[k].equals(a[j]))
    69                 {j--;break;}
    70             else
    71                 continue;
    72              }
    73         
    74     }
    75     
    76     for(j=0;j<chutishu;j++){%>
    77     <%=j+1+""+a[j]%><br>
    78     <%} %>
    79     
    80 </body>
    81 </html>
  • 相关阅读:
    矩阵距离
    CF409D Big Data
    AT2685 i18n
    P3366 【模板】最小生成树
    P3367 【模板】并查集
    ISBN(洛谷P1055)
    关于数组
    0021---一元一次方程
    0020---求圆锥体积
    0019---求圆台的体积
  • 原文地址:https://www.cnblogs.com/ghs1065248758/p/6486673.html
Copyright © 2011-2022 走看看