---恢复内容开始---
test.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<body background="C:\Users\a\Desktop/222.jpg">
<meta charset="utf-8">
<%
int x = Integer.parseInt(request.getParameter("number"));
String values[] = new String[x];
int sum[]=new int[x];
int i;
for(i=0;i<x;i++)
{
int randNumber1 = (int)Math.floor(Math.random()*100+1);
int randNumber2 = (int)Math.floor(Math.random()*100+1);
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<body background="C:\Users\a\Desktop/222.jpg">
<meta charset="utf-8">
<%
int x = Integer.parseInt(request.getParameter("number"));
String values[] = new String[x];
int sum[]=new int[x];
int i;
for(i=0;i<x;i++)
{
int randNumber1 = (int)Math.floor(Math.random()*100+1);
int randNumber2 = (int)Math.floor(Math.random()*100+1);
int fuhao=(int)Math.floor(Math.random()*4+1);
if(fuhao==1){
values[i]=randNumber1+"+"+randNumber2+"=";
sum[i]=randNumber1+randNumber2;
}
if(fuhao==2){
if(randNumber1>randNumber2){
values[i]=randNumber1+"-"+randNumber2+"=";
sum[i]=randNumber1-randNumber2;
}
else{
values[i]=randNumber2+"-"+randNumber1+"=";
sum[i]=randNumber2-randNumber1;
}
}
if(fuhao==3){
values[i]=randNumber1+"*"+randNumber2+"=";
sum[i]=randNumber1*randNumber2;
}
if(fuhao==4){
if(randNumber1<randNumber2)
{
int a=0;
a=randNumber1;
randNumber1=randNumber2;
randNumber2=a;
}
if(randNumber2==0){
randNumber2=1;
values[i]=randNumber1+"/"+randNumber2+"=";
sum[i]=randNumber1/randNumber2;
}
else{
values[i]=randNumber1+"/"+randNumber2+"=";
sum[i]=randNumber1/randNumber2;
}
}
}
%>
<title>Insert title here</title>
</head>
<body>
<form action="NewFile1.jsp">
<table>
<tr>
<td>题目</td>
<td>答案</td>
</tr>
<%
for(int j=0;j<x;j++){
%>
<tr>
<td><%=values[j] %></td>
<td><input type="text" name="results" /></td>
<td><input type="hidden" name="answer" value=<%=sum[j] %>></td>
</tr>
if(fuhao==1){
values[i]=randNumber1+"+"+randNumber2+"=";
sum[i]=randNumber1+randNumber2;
}
if(fuhao==2){
if(randNumber1>randNumber2){
values[i]=randNumber1+"-"+randNumber2+"=";
sum[i]=randNumber1-randNumber2;
}
else{
values[i]=randNumber2+"-"+randNumber1+"=";
sum[i]=randNumber2-randNumber1;
}
}
if(fuhao==3){
values[i]=randNumber1+"*"+randNumber2+"=";
sum[i]=randNumber1*randNumber2;
}
if(fuhao==4){
if(randNumber1<randNumber2)
{
int a=0;
a=randNumber1;
randNumber1=randNumber2;
randNumber2=a;
}
if(randNumber2==0){
randNumber2=1;
values[i]=randNumber1+"/"+randNumber2+"=";
sum[i]=randNumber1/randNumber2;
}
else{
values[i]=randNumber1+"/"+randNumber2+"=";
sum[i]=randNumber1/randNumber2;
}
}
}
%>
<title>Insert title here</title>
</head>
<body>
<form action="NewFile1.jsp">
<table>
<tr>
<td>题目</td>
<td>答案</td>
</tr>
<%
for(int j=0;j<x;j++){
%>
<tr>
<td><%=values[j] %></td>
<td><input type="text" name="results" /></td>
<td><input type="hidden" name="answer" value=<%=sum[j] %>></td>
</tr>
<%
}
%>
<tr>
<td>
<input type="submit" value="提交"/>
</td>
</tr>
</table>
</form>
</body>
</html>
}
%>
<tr>
<td>
<input type="submit" value="提交"/>
</td>
</tr>
</table>
</form>
</body>
</html>
---恢复内容结束---
NewFile.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/111.jpg">
<h1>网页版四则运算自动出题系统</h1>
<form action="test.jsp" method="get">
<form action="NewFile1.jsp" method="get">
<table>
<tr>
<td>题数</td>
<td>
<input type="text" name="number">
<input type="submit" value="开始答题"/></td>
</tr>
</table>
</form>
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/111.jpg">
<h1>网页版四则运算自动出题系统</h1>
<form action="test.jsp" method="get">
<form action="NewFile1.jsp" method="get">
<table>
<tr>
<td>题数</td>
<td>
<input type="text" name="number">
<input type="submit" value="开始答题"/></td>
</tr>
</table>
</form>
</body>
</html>
</html>
NewFile1.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/333.jpg">
<%
String results[] = request.getParameterValues("results");
String answer[] = request.getParameterValues("answer");
int tr = 0;
int fa = 0;
for(int i=0;i<results.length;i++){
if(results[i].equals(answer[i])){
tr++;%>
<p>第<%=i+1 %>题正确</p>
<%
}else{
fa++;%>
<p>第<%=i+1 %>题错误,输入为<%=results[i] %>,正确答案为<%=answer[i] %></p>
<%
}
}
%>
<h2>
你答对了<%=tr %>题,答错了<%=fa %>题
</h2>
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/333.jpg">
<%
String results[] = request.getParameterValues("results");
String answer[] = request.getParameterValues("answer");
int tr = 0;
int fa = 0;
for(int i=0;i<results.length;i++){
if(results[i].equals(answer[i])){
tr++;%>
<p>第<%=i+1 %>题正确</p>
<%
}else{
fa++;%>
<p>第<%=i+1 %>题错误,输入为<%=results[i] %>,正确答案为<%=answer[i] %></p>
<%
}
}
%>
<h2>
你答对了<%=tr %>题,答错了<%=fa %>题
</h2>
<form action="NewFile.jsp">
<input type="submit" value="重新开始答题"/></td>
<input type="submit" value="重新开始答题"/></td>
<a href="jieshu.jsp"> 结束<a>
</body>
</html>
</html>
jieshu.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/444.jpg">
</body>
</html>
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\Users\a\Desktop/444.jpg">
</body>
</html>
总的来说,这次web还是比较简单后,一开始做的是很没有头绪,这一篇代码那时候也还是抄别人的看着,然后一点一点再把别人的这个学下来,有不懂的就问问,也就会了。现在再看觉得还是挺简单的。嗯