<%@ 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=UTF-8">
7 <title>Insert title here</title>
8 <style type="text/css">
9 body
10 {
11 background-image: url(image/19.jpg);
12 }
13 </style>
14 </head>
15 <body>
16 <%
17 try
18 {
19 int tishu=Integer.parseInt(request.getParameter("geshu"));
20 int fanwei=Integer.parseInt(request.getParameter("fanwei"));
21 session.setAttribute("tishu", tishu);
22 session.setAttribute("fanwei", fanwei);
23 response.setHeader("refresh","0;url = zhengshu.jsp");
24 }
25 catch(Exception e)
26 {
27 %>
28 <script type="text/javascript">
29 alert("输入错误,点击确定返回重新输入!!!")
30 </script>
31 <%
32 response.setHeader("refresh","0;url = error.jsp");
33 }
34 %>
35 </body>
36 </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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<form id="form2" name="form2" method="post" action="chaundi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</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>
<style type="text/css">
body
{
background-image: url(image/19.jpg);
}
</style>
</head>
<body>
<%
try
{
int tishu=Integer.parseInt(request.getParameter("geshu"));
int fanwei=Integer.parseInt(request.getParameter("fanwei"));
session.setAttribute("tishu", tishu);
session.setAttribute("fanwei", fanwei);
response.setHeader("refresh","0;url = fenshu.jsp");
}
catch(Exception e)
{
%> <script type="text/javascript">
alert("输入错误,点击确定返回重新输入!!!")
</script>
<%
response.setHeader("refresh","0;url = fenerror.jsp");
}
%>
</body>
</html>

  

 <%@ 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=UTF-8">
7 <title>Insert title here</title>
8 <style type="text/css">
9 body
10 {
11 background-image: url(image/7.jpg);
12 }
13 </style>
14 </head>
15 <body>
16 <form id="form2" name="form2" method="post" action="fenchuandi.jsp">
17 <div style="text-align:center;color:#F09">
18 <br>
19 <br>
20 <br>
21 <br>
22 <br>
23 <br>
24 请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
25 请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
26 <input name="" type="submit" value="提交" />
27 </div>
28 </form>
29 </body>
30 </html>

  

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8" import="java.util.Random"%>
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=UTF-8">
7 <title>Insert title here</title>
8 <style type="text/css">
9 body
10 {
11 background-image: url(image/4.jpg);
12 }
13 </style>
14 </head>
15 <body>
16 <%!
17 class Suan2//真分数的运算类
18 {
19 public int m,n,x,y,c;//定义4个变量,还有一个符号变量
20 public Random random=new Random();
21 String s;//生成的计算式储存咋m里面
22 int fanwei;
23 public void shengcheng(int fanwei1)
24 {
25 fanwei=fanwei1;
26 c=random.nextInt(4);
27 x=random.nextInt(fanwei);
28 y=random.nextInt(fanwei);
29 m=random.nextInt(fanwei);
30 n=random.nextInt(fanwei);//生成4个随机数在50以内,赋给x,y,m,n
31 String fuhao;
32 for(int i=0;;i++)
33 {
34 if(x==0)//不能生成0
35 {
36 x=random.nextInt(fanwei);
37 }
38 else
39 {
40 break;
41 }
42 }
43 for(int i=0;;i++)
44 {
45 if(y==0||y==x)//不能生成0
46 {
47 y=random.nextInt(fanwei);
48 }
49 else
50 {
51 break;
52 }
53 }
54 for(int i=0;;i++)
55 {
56 if(m==0)//不能生成0
57 {
58 m=random.nextInt(fanwei);
59 }
60 else
61 {
62 break;
63 }
64 }
65 for(int i=0;;i++)
66 {
67 if(n==0||m==n)//不能生成0
68 {
69 n=random.nextInt(fanwei);
70 }
71 else
72 {
73 break;
74 }
75 }
76 if(c==0)//通整数一样,0是加法,1减法,2乘法,3除法
77 {
78 fuhao="+";
79 }
80 else if(c==1)
81 {
82 fuhao="-";
83 }
84 else if(c==2)
85 {
86 fuhao="*";
87 }
88 else
89 {
90 fuhao="/";
91 }
92 int gongyue=Gongyue(x,y);
93 x=x/gongyue;
94 y=y/gongyue;
95 gongyue=Gongyue(m,n);
96 m=m/gongyue;
97 n=n/gongyue;
98 }
99 public String shuchu()//定义输出函数
100 {
101 if(c==0)
102 {
103 if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
104 {
105 s=y+"/"+x+" + "+n+"/"+m+"=";
106 return jisuan(x,y,m,n,c);//返回计算结果
107 }
108 else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
109 {
110 s=y+"/"+x+" + "+m+"/"+n+"=";
111 return jisuan(x,y,n,m,c);//返回计算结果
112 }
113 else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
114 {
115 s=x+"/"+y+" + "+n+"/"+m+"=";
116 return jisuan(y,x,m,n,c);//返回计算结果
117 }
118 else//生成的分母必须大于分子,输出不同的结果
119 {
120 s=x+"/"+y+" + "+m+"/"+n+"=";
121 return jisuan(y,x,n,m,c);//返回计算结果
122 }
123 }
124 else if(c==1)
125 {
126 double x1=Double.parseDouble(String.valueOf(x));
127 double y1=Double.parseDouble(String.valueOf(y));
128 double m1=Double.parseDouble(String.valueOf(m));
129 double n1=Double.parseDouble(String.valueOf(n));
130 if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
131 {
132 if((y1/x1)>(n1/m1))
133 {
134 s=y+"/"+x+" - "+n+"/"+m+"=";
135 return jisuan(x,y,m,n,c);//返回计算结果
136 }
137 else
138 {
139 s=n+"/"+m+" - "+y+"/"+x+"=";
140 return jisuan(m,n,x,y,c);//返回计算结果
141 }
142 }
143 else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
144 {
145 if((y1/x1)>(m1/n1))//减数必须大于被减数
146 {
147 s=y+"/"+x+" - "+m+"/"+n+"=";
148 return jisuan(x,y,n,m,c);//返回计算结果
149 }
150 else//减数必须大于被减数
151 {
152 s=m+"/"+n+" - "+y+"/"+x+"=";
153 return jisuan(n,m,x,y,c);//返回计算结果
154 }
155 }
156 else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
157 {
158 if((x1/y1)>(n1/m1))//减数必须大于被减数
159 {
160 s=x+"/"+y+" - "+n+"/"+m+"=";
161 return jisuan(y,x,m,n,c);
162 }
163 else//减数必须大于被减数
164 {
165 s=n+"/"+m+" - "+x+"/"+y+"=";
166 return jisuan(m,n,y,x,c);//返回计算结果
167 }
168 }
169 else
170 {
171 if((x1/y1)>(m1/n1))//生成的分母必须大于分子,输出不同的结果//减数必须大于被减数
172 {
173 s=x+"/"+y+" - "+m+"/"+n+"=";
174 return jisuan(y,x,n,m,c);//返回计算结果
175 }
176 else//减数必须大于被减数
177 {
178 s=m+"/"+n+" - "+x+"/"+y+"=";
179 return jisuan(n,m,y,x,c);//返回计算结果
180 }
181 }
182 }
183 else if(c==2)
184 {
185 if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
186 {
187 s=y+"/"+x+" * "+n+"/"+m+"=";
188 return jisuan(x,y,m,n,c);//返回计算结果
189 }
190 else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
191 {
192 s=y+"/"+x+" * "+m+"/"+n+"=";
193 return jisuan(x,y,n,m,c);//返回计算结果
194 }
195 else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
196 {
197 s=x+"/"+y+" * "+n+"/"+m+"=";
198 return jisuan(y,x,m,n,c);
199 }
200 else//生成的分母必须大于分子,输出不同的结果
201 {
202 s=x+"/"+y+" * "+m+"/"+n+"=";
203 return jisuan(y,x,n,m,c);//返回计算结果
204 }
205 }
206 else
207 {
208 if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
209 {
210 s=y+"/"+x+" / "+n+"/"+m+"=";
211 return jisuan(x,y,m,n,c);//返回计算结果
212 }
213 else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
214 {
215 s=y+"/"+x+" / "+m+"/"+n+"=";
216 return jisuan(x,y,n,m,c);//返回计算结果
217 }
218 else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
219 {
220 s=x+"/"+y+" / "+n+"/"+m+"=";
221 return jisuan(y,x,m,n,c);//返回计算结果
222 }
223 else//生成的分母必须大于分子,输出不同的结果
224 {
225 s=x+"/"+y+" / "+m+"/"+n+"=";
226 return jisuan(y,x,n,m,c);//返回计算结果
227 }
228 }
229 }
230 public String jisuan(int a,int b,int c,int d,int m)//计算结果的函数
231 {
232 String daan;
233 int gongyue,gongbei;
234 if(m==0)//加法计算的结果算法
235 {
236 gongbei=Gongbei(a,c);//求两个分母的最小公倍数
237 int s1,s2,s3;
238 s1=gongbei/a;
239 s2=gongbei/c;
240 s3=b*s1+d*s2;
241 if(s3==gongbei)
242 {
243 return("1");
244 }
245 else
246 {
247 gongyue=Gongyue(s3,gongbei);
248 int fenzi=s3/gongyue,fenmu=gongbei/gongyue;
249 if(fenzi<fenmu)
250 {
251 daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
252 return daan;
253 }
254 else
255 {
256 int zhi=fenzi/fenmu;
257 daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
258 return daan;
259 }
260 }
261 }
262 else if(m==1)//减法计算的结果算法
263 {
264 gongbei=Gongbei(a,c);
265 int s1,s2,s3;
266 s1=gongbei/a;
267 s2=gongbei/c;
268 s3=b*s1-d*s2;
269 if(s3==gongbei)
270 {
271 return("1");
272 }
273 else
274 {
275 if(s3==0)
276 {
277 daan=String.valueOf("0");
278 return daan;
279 }
280 else
281 {
282 gongyue=Gongyue(s3,gongbei);
283 int fenzi=s3/gongyue,fenmu=gongbei/gongyue;
284 if(fenzi<fenmu)
285 {
286 daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
287 return daan;
288 }
289 else
290 {
291 int zhi=fenzi/fenmu;
292 daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
293 return daan;
294 }
295 }
296 }
297 }
298 else if(m==2)//乘法计算的结果算法
299 {
300 int s1,s2;
301 s1=a*c;
302 s2=b*d;
303 if(s1==s2)
304 {
305 return("1");
306 }
307 else
308 {
309 gongyue=Gongyue(s1,s2);
310 int fenzi=s2/gongyue,fenmu=s1/gongyue;
311 if(fenzi<fenmu)
312 {
313 daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
314 return daan;
315 }
316 else
317 {
318 int zhi=fenzi/fenmu;
319 daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
320 return daan;
321 }
322 }
323 }
324 else//除法计算的结果算法
325 {
326 int s1,s2;
327 s1=a*d;
328 s2=b*c;
329 if(s1==s2)
330 {
331 return("1");
332 }
333 else
334 {
335 gongyue=Gongyue(s1,s2);
336 int fenzi=s2/gongyue,fenmu=s1/gongyue;
337 if(fenzi<fenmu)
338 {
339 daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
340 return daan;
341 }
342 else
343 {
344 int zhi=fenzi/fenmu;
345 daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
346 return daan;
347 }
348 }
349 }
350 }
351 public int Gongbei(int a,int c)//求最小公倍数的函数
352 {
353 int gongbei;
354 if(a>c)
355 {
356 gongbei=a;//公倍数从大的开始
357 while(gongbei<=a*c)
358 {
359 if(gongbei%a==0&&gongbei%c==0)
360 {
361 break;
362 }
363 gongbei++;
364 }
365 }
366 else
367 {
368 gongbei=c;//公倍数从大的开始
369 while(gongbei<=a*c)
370 {
371 if(gongbei%a==0&&gongbei%c==0)
372 {
373 break;
374 }
375 gongbei++;
376 }
377 }
378 return gongbei;
379 }
380 public int Gongyue(int gongbei,int s3)//求最大公约数的函数
381 {
382 int i=1,gongyue=0;
383 if(gongbei>s3)//公约数从1到最小的数
384 {
385 while(i<=s3)
386 {
387 if(gongbei%i==0&&s3%i==0)
388 {
389 gongyue=i;
390 }
391 i++;
392 }
393 return gongyue;
394 }
395 else
396 {
397 while(i<=gongbei)
398 {
399 if(gongbei%i==0&&s3%i==0)
400 {
401 gongyue=i;
402 }
403 i++;
404 }
405 return gongyue;
406 }
407 }
408 public int jianyan(String a[],int l)//检验是否生成重复计算式的函数
409 {
410 int flag=1;
411 for(int i=0;i<l;i++)
412 {
413 if(s.equals(a[i]))
414 {
415 flag=0;
416 break;
417 }
418 }
419 return flag;
420 }
421 }
422 Random random=new Random();
423 int tishu;
424 int fanwei;
425 int m=0;
426 String shuju[]=new String[10000];
427 int flag=0;
428 Suan2 a=new Suan2();
429 String daan,daan1;
430 %>
431 <%
432 tishu=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
433 fanwei=Integer.parseInt((String.valueOf(session.getAttribute("fanwei"))));
434 session.setAttribute("tishu", tishu);
435 if(m<tishu)
436 {
437 a.shengcheng(fanwei);
438 String f=a.shuchu();
439 shuju[m]=a.s;
440 flag=a.jianyan(shuju, m);//返回是否有重复
441 if(flag==1)//如果没有就是1
442 {
443 if(m+1==tishu)
444 {daan=a.shuchu();
445 session.setAttribute("shuju", shuju[m]);
446 session.setAttribute("daan", daan);
447 session.setAttribute("m", m);
448 %>
449 <form id="form2" name="form2" method="post" action="fenshuhuoqu.jsp">
450 <div style="text-align:center">
451 <br>
452 <br>
453 <br>
454 <br>
455 <br>
456 <br>
457 <br>
458 <br>
459 <br>
460 <br>
461 <br>
462 <br>
463 <br>
464 <%out.print(m+1+"."+shuju[m]+"=");
465 m=0;%>
466 <br>
467 <br>
468 <br>
469 <br>
470 请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
471 <input name="" type="submit" value="提交" />
472 </div>
473 </form>
474 <%
475 }
476 else
477 {
478 daan=a.shuchu();
479 session.setAttribute("shuju", shuju[m]);
480 session.setAttribute("daan", daan);
481 session.setAttribute("m", m);
482 %>
483 <form id="form2" name="form2" method="post" action="fenshuhuoqu.jsp">
484 <div style="text-align:center">
485 <br>
486 <br>
487 <br>
488 <br>
489 <br>
490 <br>
491 <br>
492 <br>
493 <br>
494 <br>
495 <br>
496 <br>
497 <br>
498 <%out.print(m+1+"."+shuju[m]+"=");%>
499 <br>
500 <br>
501 <br>
502 <br>
503 请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
504 <input name="" type="submit" value="下一个" />
505 </div>
506 </form>
507 <%
508 m++;
509 flag=0;
510 }
511
512 }
513 else
514 {
515 response.setHeader("refresh","0;url = zhengshu.jsp");
516 }
517 }
518 %>
519 </body>
520 </html>

  

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8" import="java.sql.Connection" import="java.sql.DriverManager"%>
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=UTF-8">
7 <title>Insert title here</title>
8 <style type="text/css">
9 body
10 {
11 background-image: url(image/18.jpg);
12 }
13 </style>
14 </head>
15 <body>
16 <%!
17 int tishu1;
18 String error="",zhengque="";
19 %>
20 <%
21 try
22 {
23 Connection con = null; //定义一个MYSQL链接对象
24 Class.forName("com.mysql.jdbc.Driver").newInstance(); //MYSQL驱动
25 con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "20153246"); //链接本地MYSQL
26 java.sql.Statement stmt; //创建声明
27 stmt = con.createStatement();
28 String shuju=String.valueOf(session.getAttribute("shuju"));
29 String daan=String.valueOf(session.getAttribute("daan"));
30 int m=Integer.parseInt(String.valueOf(session.getAttribute("m")));
31 tishu1=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
32 String daan1=request.getParameter("daan1");
33 String sql="INSERT INTO 真分数的四则计算 (shizi,result,userresult) VALUES ('"+shuju+" = "+"','"+daan+"','"+daan1+"')";
34 stmt.executeUpdate(sql);
35 if(daan.equals(daan1))
36 {
37 zhengque=zhengque+String.valueOf(m+1)+",";
38 }
39 else
40 {
41 error=error+String.valueOf(m+1)+",";
42 }
43 if(m+1==tishu1)
44 {
45 sql="INSERT INTO Grade (zhengque,cuowu) VALUES ('"+zhengque+"','"+error+"')";
46 stmt.executeUpdate(sql);
47
48 %>
49 <form id="form2" name="form2" method="post" action="xuanze.html">
50 <div style="text-align:center;color:#F00">
51 <strong>
52 <br>
53 <br>
54 <br>
55 <br>
56 <br>
57 <br>
58 <br>
59 <br>
60 <br>
61 <br>
62 <br>
63 <br>
64 <br>
65 <br>
66 <%
67 out.print("正确的题目是:"+zhengque+"<br>"+"错误的题目是:"+error+"<br>"+"点击确定返回主界面");
68 zhengque="";
69 error=""; %>
70 <input name="" type="submit" value="确定" />
71 </strong>
72 </div>
73 </form>
74 <%
75 }
76 else
77 {
78 response.setHeader("refresh","0;url = fenshu.jsp");
79 }
80 }
81 catch (Exception e)
82 {
83 System.out.print("MYSQL ERROR:" + e.getMessage());
84 }
85 %>
86 </body>
87 </html>
 

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.Random"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/4.jpg);
}
</style>
</head>
<body>
<%!
class Suan1//生成整数计算的类
{
public int x,y,c;//定义两个变量,还有一个符号变量
public Random random=new Random();//定义随机数
String m;//生成的计算式储存咋m里面
int fanwei;
public String shengcheng(int fanwei1)//自动生成数的函数
{
fanwei=fanwei1;
c=random.nextInt(4);//生成符号
String fuhao;
x=random.nextInt(fanwei);//生成100以内的自然数
y=random.nextInt(fanwei);
if(c==0)//0是加法
{
fuhao="+";
m=String.valueOf(x)+fuhao+String.valueOf(y); }
else if(c==1)//1是减法
{
fuhao="-";
if(x>=y)
{
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
m=String.valueOf(y)+fuhao+String.valueOf(x);
}
}
else if(c==2)
{
fuhao="*";
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
fuhao="/";
for(int i=0;;i++)
{
if(y==0)
{
y=random.nextInt(fanwei);
}
else
{
break;
}
}
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
return m; }
public String shuchu()//定义输出函数
{
if(c==0)
{
return (String.valueOf(x+y));//并且返回计算的结果
}
else if(c==1)
{
if(x>=y)//将较大的数放在前面,不能出现负数
{
return (String.valueOf(x-y));
}
else
{
return (String.valueOf(y-x));
}
}
else if(c==2)
{
return (String.valueOf(x*y));
}
else
{
if(x%y==0)
{
return (String.valueOf(x/y));
}
else
{
if(x>y)
{
int shang=x/y;
int yushu=x-y*shang;
return (String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y));
}
else
{
return (String.valueOf(x)+"/"+String.valueOf(y));
}
}
}
}
public int fanhuic()
{
return c;
}
public int jianyan(String a[],int s)//检验是否有重复的式子,如果有返回0,没有就返回1
{
int flag=1;
for(int i=0;i<s;i++)
{
if(m.equals(a[i]))//数组a里面是生成的式子
{
flag=0;
break;
}
}
return flag;
}
}
class Suan2//真分数的运算类
{
public int m,n,x,y,c;//定义4个变量,还有一个符号变量
public Random random=new Random();
String s;//生成的计算式储存咋m里面
int fanwei;
public void shengcheng(int fanwei1)
{
fanwei=fanwei1;
c=random.nextInt(4);
x=random.nextInt(fanwei);
y=random.nextInt(fanwei);
m=random.nextInt(fanwei);
n=random.nextInt(fanwei);//生成4个随机数在50以内,赋给x,y,m,n
String fuhao;
for(int i=0;;i++)
{
if(x==0)//不能生成0
{
x=random.nextInt(fanwei);
}
else
{
break;
}
}
for(int i=0;;i++)
{
if(y==0||y==x)//不能生成0
{
y=random.nextInt(fanwei);
}
else
{
break;
}
}
for(int i=0;;i++)
{
if(m==0)//不能生成0
{
m=random.nextInt(fanwei);
}
else
{
break;
}
}
for(int i=0;;i++)
{
if(n==0||m==n)//不能生成0
{
n=random.nextInt(fanwei);
}
else
{
break;
}
}
if(c==0)//通整数一样,0是加法,1减法,2乘法,3除法
{
fuhao="+";
}
else if(c==1)
{
fuhao="-";
}
else if(c==2)
{
fuhao="*";
}
else
{
fuhao="/";
}
int gongyue=Gongyue(x,y);
x=x/gongyue;
y=y/gongyue;
gongyue=Gongyue(m,n);
m=m/gongyue;
n=n/gongyue;
}
public String shuchu()//定义输出函数
{
if(c==0)
{
if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" + "+n+"/"+m+"=";
return jisuan(x,y,m,n,c);//返回计算结果
}
else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" + "+m+"/"+n+"=";
return jisuan(x,y,n,m,c);//返回计算结果
}
else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" + "+n+"/"+m+"=";
return jisuan(y,x,m,n,c);//返回计算结果
}
else//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" + "+m+"/"+n+"=";
return jisuan(y,x,n,m,c);//返回计算结果
}
}
else if(c==1)
{
double x1=Double.parseDouble(String.valueOf(x));
double y1=Double.parseDouble(String.valueOf(y));
double m1=Double.parseDouble(String.valueOf(m));
double n1=Double.parseDouble(String.valueOf(n));
if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
if((y1/x1)>(n1/m1))
{
s=y+"/"+x+" - "+n+"/"+m+"=";
return jisuan(x,y,m,n,c);//返回计算结果
}
else
{
s=n+"/"+m+" - "+y+"/"+x+"=";
return jisuan(m,n,x,y,c);//返回计算结果
}
}
else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
{
if((y1/x1)>(m1/n1))//减数必须大于被减数
{
s=y+"/"+x+" - "+m+"/"+n+"=";
return jisuan(x,y,n,m,c);//返回计算结果
}
else//减数必须大于被减数
{
s=m+"/"+n+" - "+y+"/"+x+"=";
return jisuan(n,m,x,y,c);//返回计算结果
}
}
else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
if((x1/y1)>(n1/m1))//减数必须大于被减数
{
s=x+"/"+y+" - "+n+"/"+m+"=";
return jisuan(y,x,m,n,c);
}
else//减数必须大于被减数
{
s=n+"/"+m+" - "+x+"/"+y+"=";
return jisuan(m,n,y,x,c);//返回计算结果
}
}
else
{
if((x1/y1)>(m1/n1))//生成的分母必须大于分子,输出不同的结果//减数必须大于被减数
{
s=x+"/"+y+" - "+m+"/"+n+"=";
return jisuan(y,x,n,m,c);//返回计算结果
}
else//减数必须大于被减数
{
s=m+"/"+n+" - "+x+"/"+y+"=";
return jisuan(n,m,y,x,c);//返回计算结果
}
}
}
else if(c==2)
{
if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" * "+n+"/"+m+"=";
return jisuan(x,y,m,n,c);//返回计算结果
}
else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" * "+m+"/"+n+"=";
return jisuan(x,y,n,m,c);//返回计算结果
}
else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" * "+n+"/"+m+"=";
return jisuan(y,x,m,n,c);
}
else//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" * "+m+"/"+n+"=";
return jisuan(y,x,n,m,c);//返回计算结果
}
}
else
{
if(x>y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" / "+n+"/"+m+"=";
return jisuan(x,y,m,n,c);//返回计算结果
}
else if(x>y&&m<n)//生成的分母必须大于分子,输出不同的结果
{
s=y+"/"+x+" / "+m+"/"+n+"=";
return jisuan(x,y,n,m,c);//返回计算结果
}
else if(x<y&&m>n)//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" / "+n+"/"+m+"=";
return jisuan(y,x,m,n,c);//返回计算结果
}
else//生成的分母必须大于分子,输出不同的结果
{
s=x+"/"+y+" / "+m+"/"+n+"=";
return jisuan(y,x,n,m,c);//返回计算结果
}
}
}
public String jisuan(int a,int b,int c,int d,int m)//计算结果的函数
{
String daan;
int gongyue,gongbei;
if(m==0)//加法计算的结果算法
{
gongbei=Gongbei(a,c);//求两个分母的最小公倍数
int s1,s2,s3;
s1=gongbei/a;
s2=gongbei/c;
s3=b*s1+d*s2;
if(s3==gongbei)
{
return("1");
}
else
{
gongyue=Gongyue(s3,gongbei);
int fenzi=s3/gongyue,fenmu=gongbei/gongyue;
if(fenzi<fenmu)
{
daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
else
{
int zhi=fenzi/fenmu;
daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
}
}
else if(m==1)//减法计算的结果算法
{
gongbei=Gongbei(a,c);
int s1,s2,s3;
s1=gongbei/a;
s2=gongbei/c;
s3=b*s1-d*s2;
if(s3==gongbei)
{
return("1");
}
else
{
if(s3==0)
{
daan=String.valueOf("0");
return daan;
}
else
{
gongyue=Gongyue(s3,gongbei);
int fenzi=s3/gongyue,fenmu=gongbei/gongyue;
if(fenzi<fenmu)
{
daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
else
{
int zhi=fenzi/fenmu;
daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
}
}
}
else if(m==2)//乘法计算的结果算法
{
int s1,s2;
s1=a*c;
s2=b*d;
if(s1==s2)
{
return("1");
}
else
{
gongyue=Gongyue(s1,s2);
int fenzi=s2/gongyue,fenmu=s1/gongyue;
if(fenzi<fenmu)
{
daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
else
{
int zhi=fenzi/fenmu;
daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
}
}
else//除法计算的结果算法
{
int s1,s2;
s1=a*d;
s2=b*c;
if(s1==s2)
{
return("1");
}
else
{
gongyue=Gongyue(s1,s2);
int fenzi=s2/gongyue,fenmu=s1/gongyue;
if(fenzi<fenmu)
{
daan=String.valueOf(fenzi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
else
{
int zhi=fenzi/fenmu;
daan=String.valueOf(zhi)+"‘"+String.valueOf(fenzi-fenmu*zhi)+"/"+String.valueOf(fenmu);//通分
return daan;
}
}
}
}
public int Gongbei(int a,int c)//求最小公倍数的函数
{
int gongbei;
if(a>c)
{
gongbei=a;//公倍数从大的开始
while(gongbei<=a*c)
{
if(gongbei%a==0&&gongbei%c==0)
{
break;
}
gongbei++;
}
}
else
{
gongbei=c;//公倍数从大的开始
while(gongbei<=a*c)
{
if(gongbei%a==0&&gongbei%c==0)
{
break;
}
gongbei++;
}
}
return gongbei;
}
public int Gongyue(int gongbei,int s3)//求最大公约数的函数
{
int i=1,gongyue=0;
if(gongbei>s3)//公约数从1到最小的数
{
while(i<=s3)
{
if(gongbei%i==0&&s3%i==0)
{
gongyue=i;
}
i++;
}
return gongyue;
}
else
{
while(i<=gongbei)
{
if(gongbei%i==0&&s3%i==0)
{
gongyue=i;
}
i++;
}
return gongyue;
}
}
public int jianyan(String a[],int l)//检验是否生成重复计算式的函数
{
int flag=1;
for(int i=0;i<l;i++)
{
if(s.equals(a[i]))
{
flag=0;
break;
}
}
return flag;
}
}
int tishu;
int fanwei;
int m=0;
Random random=new Random();
String shuju[]=new String[10000];
int flag=0;
Suan2 a=new Suan2();
Suan1 b=new Suan1();
String daan,daan1;
%>
<%
tishu=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
fanwei=Integer.parseInt((String.valueOf(session.getAttribute("fanwei"))));
session.setAttribute("tishu", tishu);
if(m<tishu)
{
int t=random.nextInt(2);
if(t==0)
{
a.shengcheng(fanwei);
String f=a.shuchu();
shuju[m]=a.s;
flag=a.jianyan(shuju, m);//返回是否有重复
if(flag==1)//如果没有就是1
{
if(m+1==tishu)
{daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="fenzhenghuoqu.jsp">
<div style="text-align:center">
<%out.print(m+1+"."+shuju[m]+"=");
m=0;%>
<br>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="fenzhenghuoqu.jsp">
<div style="text-align:center">
<%out.print(m+1+"."+shuju[m]+"=");%>
<br>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="下一个" />
</div>
</form>
<%
m++;
flag=0;
} }
else
{
response.setHeader("refresh","0;url = fenzheng.jsp");
}
}
else
{
shuju[m]=b.shengcheng(fanwei);//将生成的计算式储存咋数组里面
flag=b.jianyan(shuju, m);//返回是否有重复
if(flag==1)//如果没有就是1
{
if(m+1==tishu)
{daan=b.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="fenzhenghuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");
m=0;%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
daan=b.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="fenzhenghuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="下一个" />
</div>
</form>
<%
m++;
flag=0;
} }
else
{
response.setHeader("refresh","1;url = fenzheng.jsp");
}
} }
%>
</body>
</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=UTF-8">
7 <title>Insert title here</title>
8 </head>
9 <body>
10 <%
11 try
12 {
13 int tishu=Integer.parseInt(request.getParameter("geshu"));
14 int fanwei=Integer.parseInt(request.getParameter("fanwei"));
15 session.setAttribute("tishu", tishu);
16 session.setAttribute("fanwei", fanwei);
17 response.setHeader("refresh","0;url = fenzheng.jsp");
18 }
19 catch(Exception e)
20 {
21 %>
22
23 <script type="text/javascript">
24 alert("输入错误,点击确定返回重新输入!!!")
25 </script>
26 <%
27 response.setHeader("refresh","0;url = fenzhengerror.jsp");
28 }
29 %>
30 </body>
31 </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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<form id="form2" name="form2" method="post" action="fenzhengchuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.Connection" import="java.sql.DriverManager"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/18.jpg);
}
</style>
</head>
<body>
<%!
int tishu1;
String error="",zhengque="";
%>
<%
try
{
Connection con = null; //定义一个MYSQL链接对象
Class.forName("com.mysql.jdbc.Driver").newInstance(); //MYSQL驱动
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "20153246"); //链接本地MYSQL
java.sql.Statement stmt; //创建声明
stmt = con.createStatement();
String shuju=String.valueOf(session.getAttribute("shuju"));
String daan=String.valueOf(session.getAttribute("daan"));
int m=Integer.parseInt(String.valueOf(session.getAttribute("m")));
tishu1=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
String daan1=request.getParameter("daan1");
String sql="INSERT INTO 整数与真分数的混合四则运算 (shizi,result,userresult) VALUES ('"+shuju+" = "+"','"+daan+"','"+daan1+"')";
stmt.executeUpdate(sql);
if(daan.equals(daan1))
{
zhengque=zhengque+String.valueOf(m+1)+",";
}
else
{
error=error+String.valueOf(m+1)+",";
}
if(m+1==tishu1)
{
sql="INSERT INTO Grade (zhengque,cuowu) VALUES ('"+zhengque+"','"+error+"')";
stmt.executeUpdate(sql); %>
<form id="form2" name="form2" method="post" action="xuanze.html">
<div style="text-align:center;color:#F00">
<strong>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%
out.print("正确的题目是:"+zhengque+"<br>"+"错误的题目是:"+error+"<br>"+"点击确定返回主界面");
zhengque="";
error=""; %>
<input name="" type="submit" value="确定" />
</strong>
</div>
</form>
<%
}
else
{
response.setHeader("refresh","0;url = fenzheng.jsp");
}
}
catch (Exception e)
{
System.out.print("MYSQL ERROR:" + e.getMessage());
}
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.Connection" import="java.sql.DriverManager"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/18.jpg);
}
</style>
</head>
<body>
<%!
int tishu1;
String error="",zhengque="";
%>
<%
try
{
Connection con = null; //定义一个MYSQL链接对象
Class.forName("com.mysql.jdbc.Driver").newInstance(); //MYSQL驱动
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "20153246"); //链接本地MYSQL
java.sql.Statement stmt; //创建声明
stmt = con.createStatement();
String shuju=String.valueOf(session.getAttribute("shuju"));
String daan=String.valueOf(session.getAttribute("daan"));
int m=Integer.parseInt(String.valueOf(session.getAttribute("m")));
tishu1=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
String daan1=request.getParameter("daan1");
String sql="INSERT INTO 整数的四则计算 (shizi,result,userresult) VALUES ('"+shuju+" = "+"','"+daan+"','"+daan1+"')";
stmt.executeUpdate(sql);
if(daan.equals(daan1))
{
zhengque=zhengque+String.valueOf(m+1)+",";
}
else
{
error=error+String.valueOf(m+1)+",";
}
if(m+1==tishu1)
{
sql="INSERT INTO Grade (zhengque,cuowu) VALUES ('"+zhengque+"','"+error+"')";
stmt.executeUpdate(sql);
%>
<form id="form2" name="form2" method="post" action="xuanze.html">
<div style="text-align:center;color:#F00">
<strong>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%
out.print("正确的题目是:"+zhengque+"<br>"+"错误的题目是:"+error+"<br>"+"点击确定返回主界面");
zhengque="";
error=""; %>
<input name="" type="submit" value="确定" />
</strong>
</div>
</form>
<%
}
else
{
response.setHeader("refresh","0;url = zhengshu.jsp");
}
}
catch (Exception e)
{
System.out.print("MYSQL ERROR:" + e.getMessage());
}
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.Connection" import="java.sql.DriverManager"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/18.jpg);
}
</style>
</head>
<body>
<%!
int tishu1;
String error="",zhengque="";
%>
<%
try
{
Connection con = null; //定义一个MYSQL链接对象
Class.forName("com.mysql.jdbc.Driver").newInstance(); //MYSQL驱动
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "20153246"); //链接本地MYSQL
java.sql.Statement stmt; //创建声明
stmt = con.createStatement();
String shuju=String.valueOf(session.getAttribute("shuju"));
String daan=String.valueOf(session.getAttribute("daan"));
int m=Integer.parseInt(String.valueOf(session.getAttribute("m")));
tishu1=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
String daan1=request.getParameter("daan1");
String sql="INSERT INTO 整数的四则计算 (shizi,result,userresult) VALUES ('"+shuju+" = "+"','"+daan+"','"+daan1+"')";
stmt.executeUpdate(sql);
if(daan.equals(daan1))
{
zhengque=zhengque+String.valueOf(m+1)+",";
}
else
{
error=error+String.valueOf(m+1)+",";
}
if(m+1==tishu1)
{
sql="INSERT INTO Grade (zhengque,cuowu) VALUES ('"+zhengque+"','"+error+"')";
stmt.executeUpdate(sql);
%>
<form id="form2" name="form2" method="post" action="xuanze.html">
<div style="text-align:center;color:#F00">
<strong>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%
out.print("正确的题目是:"+zhengque+"<br>"+"错误的题目是:"+error+"<br>"+"点击确定返回主界面");
zhengque="";
error=""; %>
<input name="" type="submit" value="确定" />
</strong>
</div>
</form>
<%
}
else
{
response.setHeader("refresh","0;url = zhengshu.jsp");
}
}
catch (Exception e)
{
System.out.print("MYSQL ERROR:" + e.getMessage());
}
%>
</body>
</html> <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.Random"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/4.jpg);
}
</style>
</head>
<body>
<%!
class Suan1//生成整数计算的类
{
public int x,y,c;//定义两个变量,还有一个符号变量
public Random random=new Random();//定义随机数
String m;//生成的计算式储存咋m里面
int fanwei;
public String shengcheng(int fanwei1)//自动生成数的函数
{
fanwei=fanwei1;
c=random.nextInt(4);//生成符号
String fuhao;
x=random.nextInt(fanwei);//生成100以内的自然数
y=random.nextInt(fanwei);
if(c==0)//0是加法
{
fuhao="+";
m=String.valueOf(x)+fuhao+String.valueOf(y); }
else if(c==1)//1是减法
{
fuhao="-";
if(x>=y)
{
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
m=String.valueOf(y)+fuhao+String.valueOf(x);
}
}
else if(c==2)
{
fuhao="*";
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
fuhao="/";
for(int i=0;;i++)
{
if(y==0)
{
y=random.nextInt(fanwei);
}
else
{
break;
}
}
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
return m; }
public String shuchu()//定义输出函数
{
if(c==0)
{
return (String.valueOf(x+y));//并且返回计算的结果
}
else if(c==1)
{
if(x>=y)//将较大的数放在前面,不能出现负数
{
return (String.valueOf(x-y));
}
else
{
return (String.valueOf(y-x));
}
}
else if(c==2)
{
return (String.valueOf(x*y));
}
else
{
if(x%y==0)
{
return (String.valueOf(x/y));
}
else
{
if(x>y)
{
int shang=x/y;
int yushu=x-y*shang;
return (String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y));
}
else
{
return (String.valueOf(x)+"/"+String.valueOf(y));
}
}
}
}
public int fanhuic()
{
return c;
}
public String jisuan()
{
if(c==0)
{
return (String.valueOf(x+y));//并且返回计算的结果
}
else if(c==1)
{
if(x>=y)//将较大的数放在前面,不能出现负数
{
return (String.valueOf(x-y));
}
else
{
return (String.valueOf(y-x));
}
}
else if(c==2)
{
return (String.valueOf(x*y));
}
else
{
if(x%y==0)
{
return (String.valueOf(x/y));
}
else
{
return (String.valueOf(x)+"/"+String.valueOf(y));
}
}
}
public int jianyan(String a[],int s)//检验是否有重复的式子,如果有返回0,没有就返回1
{
int flag=1;
for(int i=0;i<s;i++)
{
if(m.equals(a[i]))//数组a里面是生成的式子
{
flag=0;
break;
}
}
return flag;
}
}
class Suan4
{
public String m;
public Random random=new Random();
public Suan1 suan=new Suan1();
public String a;
public int b,z;
public int c;
public String a1;
public int panduan;
public int x,y;
public String daan;
public int weizhi;
public double kuohao()
{
panduan=suan.fanhuic();
if(panduan==3)
{
weizhi=a.indexOf("/");
if(weizhi==-1)
{
z=Integer.parseInt(a);
return z;
}
else
{
x=Integer.parseInt(a.substring(0, weizhi));
y=Integer.parseInt(a.substring(weizhi+1));
return (Double.parseDouble(a.substring(0, weizhi))/Double.parseDouble(a.substring(weizhi+1)));
}
}
else
{
z=Integer.parseInt(a);
return z;
}
}
public String shengcheng(int fanwei)
{
a1=suan.shengcheng(fanwei);
a=suan.jisuan();
b=random.nextInt(fanwei);
int c=random.nextInt(4);
int daan1;
String fuhao;
int kuohao=random.nextInt(2);
if(c==0)//0是加法
{
fuhao="+";
}
else if(c==1)//1是减法
{
fuhao="-";
}
else
{
fuhao="*";
}
double daxiao=kuohao();
if(kuohao==0)
{
if(c==1&&daxiao<b)
{
m=String.valueOf(b)+fuhao+"("+a1+")";
if(weizhi!=-1&&panduan==3)
{
if(c==0)
{
int x1=b*y;
int x2=x+x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==1)
{
int x1=b*y;
int x2=x1-x;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==2)
{
int x2=x*b;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
}
else
{
if(c==0)
{
daan=String.valueOf(b+z);
}
else if(c==1)
{
daan=String.valueOf(b-z);
}
else
{
daan=String.valueOf(b*z);
}
}
}
else
{
m="("+a1+")"+fuhao+String.valueOf(b);
if(weizhi!=-1&&panduan==3)
{
if(c==0)
{
int x1=b*y;
int x2=x+x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==1)
{
int x1=b*y;
int x2=x-x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==2)
{
int x2=x*b;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
}
else
{
if(c==0)
{
daan=String.valueOf(z+b);
}
else if(c==1)
{
daan=String.valueOf(z-b);
}
else
{
daan=String.valueOf(z*b);
}
}
}
}
else
{
if(c==1&&daxiao>b)
{
m="("+a1+")"+fuhao+String.valueOf(b);
if(weizhi!=-1&&panduan==3)
{
if(c==0)
{
int x1=b*y;
int x2=x+x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==1)
{
int x1=b*y;
int x2=x-x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==2)
{
int x2=x*b;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
}
else
{
if(c==0)
{
daan=String.valueOf(z+b);
}
else if(c==1)
{
daan=String.valueOf(z-b);
}
else
{
daan=String.valueOf(z*b);
}
}
}
else
{
m=String.valueOf(b)+fuhao+"("+a1+")";
if(weizhi!=-1&&panduan==3)
{
if(c==0)
{
int x1=b*y;
int x2=x+x1;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==1)
{
int x1=b*y;
int x2=x1-x;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
else if(c==2)
{
int x2=x*b;
if(x2%y==0)
{
daan=String.valueOf(x2/y);
}
else
{
if(x2>y)
{
int shang=x2/y;
int yushu=x2-y*shang;
daan=String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y);
}
else
{
daan=String.valueOf(x2)+"/"+String.valueOf(y);
}
}
}
}
else
{
if(c==0)
{
daan=String.valueOf(b+z);
}
else if(c==1)
{
daan=String.valueOf(b-z);
}
else
{
daan=String.valueOf(b*z);
}
}
}
}
m=m+"=";
return m;
}
public int jianyan(String a[],int l)//检验是否重复的函数
{
int flag=1;
for(int i=0;i<l;i++)
{
if(m.equals(a[i]))
{
flag=0;
break;
}
}
return flag;
}
}
int tishu;
int fanwei;
int m=0;
String shuju[]=new String[10000];
int flag=0;
Suan4 a=new Suan4();
String daan,daan1;
String zhengque="",cuowu="";
%>
<%
tishu=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
fanwei=Integer.parseInt((String.valueOf(session.getAttribute("fanwei"))));
session.setAttribute("tishu", tishu);
if(m<tishu)//生成30个计算式
{
shuju[m]=a.shengcheng(fanwei);//将生成的计算式储存咋数组里面
flag=a.jianyan(shuju, m);//返回是否有重复
if(flag==1)//如果没有就是1
{
if(m+1==tishu)
{daan=a.daan;
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="kuohaohuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");
m=0;%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
daan=a.daan;
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="kuohaohuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="下一个" />
</div>
</form>
<%
m++;
flag=0;
} }
else
{
response.setHeader("refresh","1;url = kuohao.jsp");
}
}
%>
</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>
<%
try
{
int tishu=Integer.parseInt(request.getParameter("geshu"));
int fanwei=Integer.parseInt(request.getParameter("fanwei"));
session.setAttribute("tishu", tishu);
session.setAttribute("fanwei", fanwei);
response.setHeader("refresh","0;url = kuohao.jsp");
}
catch(Exception e)
{
%> <script type="text/javascript">
alert("输入错误,点击确定返回重新输入!!!")
</script>
<%
response.setHeader("refresh","0;url = kuohaoerror.jsp");
}
%>
</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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<form id="form2" name="form2" method="post" action="kuohaochuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<form id="form2" name="form2" method="post" action="kuohaochuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<%
String panduan=request.getParameter("xuanze");
if(panduan.equals("A"))
{
%>
<form id="form2" name="form2" method="post" action="chaundi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else if(panduan.equals("B"))
{
%>
<br>
<br>
<br>
<br>
<br>
<br>
<form id="form3" name="form4" method="post" action="fenchuandi.jsp">
<div style="text-align:center;color:#F09">
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else if(panduan.equals("C"))
{
%>
<form id="form2" name="form2" method="post" action="fenzhengchuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else if(panduan.equals("D"))
{
%>
<form id="form2" name="form2" method="post" action="yushuchuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else if(panduan.equals("E"))
{
%>
<form id="form2" name="form2" method="post" action="kuohaochuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
%>
<script type="text/javascript">
alert("输入错误,请点击确定重新输入!!!");
</script>
<%
response.setHeader("refresh","0;url = xuanze.html");
}
%>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>主界面</title>
<style type="text/css">
body
{
background-image: url(image/17.jpg);
}
</style>
</head>
<body>
<div style="text-align: center; font-family: 微软雅黑; font-size: 50px; color: #C03; "><strong><em>四则运算</em></strong></div>
<div style="text-align: center; font-family: 微软雅黑; font-size: 15px; color: #C03; "><strong><em>Welcome To User The System</em></strong></div>
<br/>
<div style="text-align: center; font-family: 微软雅黑; font-size: 20px;color: #C03;"><strong><em>请选择出题的范围</em></strong></div><br />
<form name="form1" method="post" action="panduan.jsp">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<div style="color: #C03">
<p> <strong>A:整数的四则计算<br />
B:真分数的四则计算<br />
C:整数与真分数的混合四则运算<br />
D:有余数的除法<br />
E:有括号的四则运算<br />
</strong>
</p>
</div>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<div style="text-align: center;color: #C03 ">
<strong>请选择:</strong><input name="xuanze" type="text"/>
<input name="" type="submit" value="提交" />
<input name="" type="reset" value="重置" />
</div>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.Random"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/4.jpg);
}
</style>
</head>
<body>
<%!
class Suan3//有余数的类
{
public int x,y;//定义两个变量
public String m;
public Random random=new Random();
int fanwei;
public String shengcheng(int fanwei1)//定义生成函数
{
fanwei=fanwei1;
x=random.nextInt(fanwei);
y=random.nextInt(fanwei);
for(int i=0;;i++)
{
if(y==0)
{
y=random.nextInt(fanwei);
}
else
{
break;
}
}
m=String.valueOf(x)+"/"+String.valueOf(y);//返回计算式
return m;
}
public String shuchu()//生成输出函数
{
String daan;
int shang,yushu;
shang=x/y;
yushu=x-shang*y;
daan=String.valueOf(shang)+"/"+String.valueOf(yushu);//返回计算结果
return daan;
}
public int jianyan(String a[],int l)//检验是否重复的函数
{
int flag=1;
for(int i=0;i<l;i++)
{
if(m.equals(a[i]))
{
flag=0;
break;
}
}
return flag;
}
}
int tishu;
int fanwei;
int m=0;
String shuju[]=new String[10000];
int flag=0;
Suan3 a=new Suan3();
String daan,daan1;
%>
<% tishu=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
fanwei=Integer.parseInt((String.valueOf(session.getAttribute("fanwei"))));
session.setAttribute("tishu", tishu);
if(m<tishu)
{
shuju[m]=a.shengcheng(fanwei);
flag=a.jianyan(shuju, m);//返回是否有重复
if(flag==1)//如果没有就是1
{
if(m+1==tishu)
{daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="yushuhuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");
m=0;%>
<br>
<br>
<br>
<br>
请输入商:<input name="daan1" type="text" value=""/><br /><br/>
请输入余数:<input name="daan2" type="text" value=""/><br>
<br>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="yushuhuoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");%>
<br>
<br>
<br>
<br>
请输入商:<input name="daan1" type="text" value=""/><br /><br/>
请输入余数:<input name="daan2" type="text" value=""/><br>
<br>
<input name="" type="submit" value="下一个" />
</div>
</form>
<%
m++;
flag=0;
} }
else
{
response.setHeader("refresh","0;url = yushu.jsp");
}
}
%>
</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>
<%
try
{
int tishu=Integer.parseInt(request.getParameter("geshu"));
int fanwei=Integer.parseInt(request.getParameter("fanwei"));
session.setAttribute("tishu", tishu);
session.setAttribute("fanwei", fanwei);
response.setHeader("refresh","0;url = yushu.jsp");
}
catch(Exception e)
{
%>
<script type="text/javascript">
alert("输入错误,点击确定返回重新输入!!!")
</script>
<%
response.setHeader("refresh","0;url = yushuerror.jsp");
}
%>
</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>
<style type="text/css">
body
{
background-image: url(image/7.jpg);
}
</style>
</head>
<body>
<form id="form2" name="form2" method="post" action="yushuchuangdi.jsp">
<div style="text-align:center;color:#F09">
<br>
<br>
<br>
<br>
<br>
<br>
请输入出题的个数:<input name="geshu" type="text" value=""/><br /><br/>
请选择出题的范围:<input name="fanwei" type="text" value=""/><br/><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
</body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.Connection" import="java.sql.DriverManager"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/18.jpg);
}
</style>
</head>
<body>
<%!
int tishu1;
String error="",zhengque="";
%>
<%
try
{
Connection con = null; //定义一个MYSQL链接对象
Class.forName("com.mysql.jdbc.Driver").newInstance(); //MYSQL驱动
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "20153246"); //链接本地MYSQL
java.sql.Statement stmt; //创建声明
stmt = con.createStatement();
String shuju=String.valueOf(session.getAttribute("shuju"));
String daan=String.valueOf(session.getAttribute("daan"));
int weizhi=daan.indexOf('/');
String shang1=daan.substring(0, weizhi);
String yushu1=daan.substring(weizhi+1);
int m=Integer.parseInt(String.valueOf(session.getAttribute("m")));
tishu1=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
String shang =request.getParameter("daan1");
String yushu =request.getParameter("daan2");
String sql="INSERT INTO 有余数的除法 (shizi,shang,yushu,usershang,useryushu) VALUES ('"+shuju+" = "+"','"+shang1+"','"+yushu1+"','"+shang+"','"+yushu+"')";
stmt.executeUpdate(sql);
if(daan.equals(shang+"/"+yushu))
{
zhengque=zhengque+String.valueOf(m+1)+",";
}
else
{
error=error+String.valueOf(m+1)+",";
}
if(m+1==tishu1)
{
sql="INSERT INTO Grade (zhengque,cuowu) VALUES ('"+zhengque+"','"+error+"')";
stmt.executeUpdate(sql); %>
<form id="form2" name="form2" method="post" action="xuanze.html">
<div style="text-align:center;color:#F00">
<strong>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%
out.print("正确的题目是:"+zhengque+"<br>"+"错误的题目是:"+error+"<br>"+"点击确定返回主界面");
zhengque="";
error=""; %>
<input name="" type="submit" value="确定" />
</strong>
</div>
</form>
<%
}
else
{
response.setHeader("refresh","0;url = yushu.jsp");
}
}
catch (Exception e)
{
System.out.print("MYSQL ERROR:" + e.getMessage());
}
%>
</body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.Random" import="java.sql.Connection" import="java.sql.DriverManager"%>
<!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>
<style type="text/css">
body
{
background-image: url(image/4.jpg);
}
</style>
</head>
<body>
<%!
class Suan1//生成整数计算的类
{
public int x,y,c;//定义两个变量,还有一个符号变量
public Random random=new Random();//定义随机数
String m;//生成的计算式储存咋m里面
int fanwei;
public String shengcheng(int fanwei1)//自动生成数的函数
{
fanwei=fanwei1;
c=random.nextInt(4);//生成符号
String fuhao;
x=random.nextInt(fanwei);//生成100以内的自然数
y=random.nextInt(fanwei);
if(c==0)//0是加法
{
fuhao="+";
m=String.valueOf(x)+fuhao+String.valueOf(y); }
else if(c==1)//1是减法
{
fuhao="-";
if(x>=y)
{
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
m=String.valueOf(y)+fuhao+String.valueOf(x);
}
}
else if(c==2)
{
fuhao="*";
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
else
{
fuhao="/";
for(int i=0;;i++)
{
if(y==0)
{
y=random.nextInt(fanwei);
}
else
{
break;
}
}
m=String.valueOf(x)+fuhao+String.valueOf(y);
}
return m; }
public String shuchu()//定义输出函数
{
if(c==0)
{
return (String.valueOf(x+y));//并且返回计算的结果
}
else if(c==1)
{
if(x>=y)//将较大的数放在前面,不能出现负数
{
return (String.valueOf(x-y));
}
else
{
return (String.valueOf(y-x));
}
}
else if(c==2)
{
return (String.valueOf(x*y));
}
else
{
if(x%y==0)
{
return (String.valueOf(x/y));
}
else
{
if(x>y)
{
int shang=x/y;
int yushu=x-y*shang;
return (String.valueOf(shang)+"‘"+String.valueOf(yushu)+"/"+String.valueOf(y));
}
else
{
return (String.valueOf(x)+"/"+String.valueOf(y));
}
}
}
}
public int fanhuic()
{
return c;
}
public int jianyan(String a[],int s)//检验是否有重复的式子,如果有返回0,没有就返回1
{
int flag=1;
for(int i=0;i<s;i++)
{
if(m.equals(a[i]))//数组a里面是生成的式子
{
flag=0;
break;
}
}
return flag;
}
}
int tishu;
int fanwei;
int m=0;
String shuju[]=new String[10000];
int flag=0;
Suan1 a=new Suan1();
String daan,daan1;
String zhengque="",cuowu="";
%>
<%
tishu=Integer.parseInt((String.valueOf(session.getAttribute("tishu"))));
fanwei=Integer.parseInt((String.valueOf(session.getAttribute("fanwei"))));
session.setAttribute("tishu", tishu);
if(m<tishu)//生成30个计算式
{
shuju[m]=a.shengcheng(fanwei);//将生成的计算式储存咋数组里面
flag=a.jianyan(shuju, m);//返回是否有重复
if(flag==1)//如果没有就是1
{
if(m+1==tishu)
{daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="huoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");
m=0;%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="提交" />
</div>
</form>
<%
}
else
{
daan=a.shuchu();
session.setAttribute("shuju", shuju[m]);
session.setAttribute("daan", daan);
session.setAttribute("m", m);
%>
<form id="form2" name="form2" method="post" action="huoqu.jsp">
<div style="text-align:center">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<%out.print(m+1+"."+shuju[m]+"=");%>
<br>
<br>
<br>
<br>
请输入答案:<input name="daan1" type="text" value=""/><br /><br/>
<input name="" type="submit" value="下一个" />
</div>
</form>
<%
m++;
flag=0;
} }
else
{
response.setHeader("refresh","1;url = zhengshu.jsp");
}
}
%> </body>
</html>

java-四则运算-五-网页版--with刘童格的更多相关文章

  1. 教你用纯Java实现一个网页版的Xshell(附源码)

    前言 最近由于项目需求,项目中需要实现一个WebSSH连接终端的功能,由于自己第一次做这类型功能,所以首先上了GitHub找了找有没有现成的轮子可以拿来直接用,当时看到了很多这方面的项目,例如:Gat ...

  2. java-二维数组——with 刘童格

    #include<iostream> #include<string> using namespace std; void MaxIntArray(int a[],int &a ...

  3. 如何利用WebSocket实现网页版聊天室

    花了将近一周的时间终于完成了利用WebSocket完成网页版聊天室这个小demo,期间还走过了一段"看似弯曲"的道路,但是我想其实也不算是弯路吧,因为你走过的路必将留下你的足迹.这 ...

  4. Java课程寒假之开发记账本软件(网页版)之一

    一.制定网页版记账本的基础功能 首先是下载了几个记账本APP,大致地看了一下记账本的功能:添加记录(支出,收入,自定义模板),查询流水(分类查询),账户. 二.开始做出框架 鉴于记账本有上面的功能,所 ...

  5. Vue+Element实现网页版个人简历系统

    这篇文章介绍一个使用Vue+Element实现的个人简历系统,主要用到的技术有:vue.element.css3.css定位. 作者在window10进行开发,目前只在chrome上进行过测试,没有大 ...

  6. Redis设计与实现(一~五整合版)【搬运】

    Redis设计与实现(一~五整合版) by @飘过的小牛 一 前言 项目中用到了redis,但用到的都是最最基本的功能,比如简单的slave机制,数据结构只使用了字符串.但是一直听说redis是一个很 ...

  7. 分享:计算机图形学期末作业!!利用WebGL的第三方库three.js写一个简单的网页版“我的世界小游戏”

    这几天一直在忙着期末考试,所以一直没有更新我的博客,今天刚把我的期末作业完成了,心情澎湃,所以晚上不管怎么样,我也要写一篇博客纪念一下我上课都没有听,还是通过强大的度娘完成了我的作业的经历.(当然作业 ...

  8. 实现类似 QQ音乐网页版 的单页面总结

    最近需要对创业团队的网站进行改版,而我负责前端设计和实现. 下面是一些总结与体会: 当设计完成之前,我就跟和我配合的Java 后台说用iframe实现,结果说麻烦不肯,到最后突然对我说还是用ifram ...

  9. Java、C#双语版HttpHelper类

    Java.C#双语版HttpHelper类(解决网页抓取乱码问题)   在做一些需要抓取网页的项目时,经常性的遇到乱码问题.最省事的做法是去需要抓取的网站看看具体是什么编码,然后采用正确的编码进行解码 ...

随机推荐

  1. ssh访问跳过RSA key"yes/no"验证

    通常我们再批量配置多台机器的时候经常出现通过ssh批量登录机器提示 RSA key fingerprint is ::a6:b1:c9:d7:b8::c1:::8e:f5::2b:8b. Are yo ...

  2. Powershell Get Domain Group的几种方法

    Group常见属性介绍: 一.Get-ADGroup获取群组(如下例循环获取群组的发送权限) #群组的发送权限info $groups=Get-ADGroup -filter * -SearchSco ...

  3. c++相关知识

    0.C语言基础知识及系统相关:http://c.biancheng.net/cpp/u/jiaocheng/ 1.C++ include观点与机制:http://developer.51cto.com ...

  4. centos7 Docker Compose 的安装

    [root@localhost ~]# curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose ...

  5. JS练习--自动生成100个li

    点击按钮,自动生成100个li,红.黄.蓝.绿四种颜色的顺序显示出现在页面中 CSS: ;;} ul,li{list-style: none;} #ul1{position: relative;} # ...

  6. 在windows上搭建redis集群

    一 所需软件 Redis.Ruby语言运行环境.Redis的Ruby驱动redis-xxxx.gem.创建Redis集群的工具redis-trib.rb 二 安装配置redis redis下载地址   ...

  7. Pig、Hive、MapReduce 解决分组 Top K 问题(转)

    问题: 有如下数据文件 city.txt (id, city, value) cat city.txt 1 wh 5002 bj 6003 wh 1004 sh 4005 wh 2006 bj 100 ...

  8. s5_day4作业

    # #流程控制练习题: # #==========>基础部分 # #练习一: # if True or False and False: # print('yes') # else: # pri ...

  9. python识别验证码

    1.tesseract-ocr安装 tesseract-ocr windows下载地址 http://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr- ...

  10. webdeploy启用备份 msdeploy 启用backup

    前提准备:完整安装Microsoft Web Deploy 3 下载页面:WebDeploy_amd64_zh-CN.msi msdeploy 同步站点 命令所在目录C:\Program Files\ ...