程序设计思路:建立数组并且把随机数保存在数组中,已经实现数值范围等功能,但括号,结果判断无法使用 会继续努力更新。
源代码:
<%@ 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>出题</title>
</head>
<body>
<form action="chuti.jsp" method="post">
<center>
<h2>自动出题</h2>
<h3><font>出题类型:<input type="radio" name="type" value="zhengshu">整数
<input type="radio" name="type" value="zhenfenshu">真分数
<input type="radio" name="type" value="douyou">均存在</font></h3>
<h3><font>出题数:<input type="text" name ="chutishu" ></font><br></h3>
数值范围<input type="text" name="xiao">
<input type="text" name="da"><br><br>
变量个数<input type="text" name="geshu"><br>
<h3>1.有乘除法 2.无乘除法</h3>
乘除法<input type="text" name="chengchu"><br>
<input type="submit" value="提交">
</form>
</center>
</form>
</body>
</html>
<%@ 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");
String Min=request.getParameter("xiao");
String Max=request.getParameter("da");
String shu = request.getParameter("geshu");
String chu = request.getParameter("chengchu");
int x=Integer.parseInt(zh);
int y=Integer.parseInt(zhh);
int min=Integer.parseInt(Min);
int max=Integer.parseInt(Max);
int z=Integer.parseInt(shu);
int xx=Integer.parseInt(chu);
int m,n,j,jj;
char []ch=new char[4];
ch[0]='+';
ch[1]='-';
ch[2]='*';
ch[3]='/';
if(y==1)
{
int []M=new int[10];
for(int ii=1;ii<=x;ii++)
{
mout.print("<br>");
String []A=new String[30];
for(int i=0;i<30;i++)
{
A[i]="";
for(int o=0;o<z;o++)
{
M[o]=(int)(Math.random()*max+min);
if(xx==1)
j=(int)(Math.random()*4+1);
else
j=(int)(Math.random()*2+1);
if(o==z-1)
A[i]=A[i]+M[o]+" =";
else
A[i]=A[i]+M[o]+" "+ch[j-1];
}
for(int k=0;k<i;k++)
{
if(A[i].equals(A[k]))
{
i--;
break;
}
}
}
for(int i=0;i<30;i++)
{
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("<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=0;k<i;k++)
{
if(B[i].equals(B[k]))
{
i--;
break;
}
}
}
for(int i=0;i<30;i++)
{
mout.print((i+1)+". "+B[i]);
mout.print("<br>");
}
mout.print("-"+ii+"-");
mout.print("<br><br><br>");
mout.print("-"+ii+"-");
mout.print("<br><br><br>");
}
}
%>
</body>
</html>
截图:
总结:通过这次更多功能的实现,括号的使用还是没有思路,会努力尽快完成,在综合功能方面实现的不是很好,会继续完善。