·主要思路:在完成控制出题界面后,根据选择控制输出,将答案计算出来,连接到数据库,其中还涉及到最大公约数计算分数运算。
源代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 出题系统 出题系统
Yunsuan.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import= "size.com.* "%> Insert title here<% 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");String hao=request.getParameter("kuohao");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 t=Integer.parseInt(hao);int m,n,j,jj;char []ch=new char[4];int a1,b1;ch[0]='+';ch[1]='-';ch[2]='*';ch[3]='/';if(y==1){ int []M=new int[10]; String []N=new String[10]; for(int ii=1;ii<=x;ii++) { mout.print("30道题目"); mout.print(""); String []A=new String[30]; a1=(int)(Math.random()*(z-1)+1); b1=a1+1; for(int i=0;i<30;i++) { A[i]=""; for(int o=0;o
"); }*/ StringBuffer temp = new StringBuffer(ss); int former = (int)(Math.random()*length+1); int end = (int)(Math.random()*length+1); while(num<=2&&former !=1&&end != length) { former = (int)(Math.random()*length+1); end = (int)(Math.random()*length+1); } if(former == 1) { temp.insert(former-1, '('); int next = (int)(Math.random()*num); while(next == 0) next = (int)(Math.random()*num); temp.insert(in[next]+1, ')'); end--; } if(former >1&&end
2) { int first = (int)(Math.random()*num);//括起来的第一个数 int next = (int)(Math.random()*num);//括起来的最后一个数 while(next-first<=1) { first = (int)(Math.random()*num);//括起来的第一个数 next = (int)(Math.random()*num);//括起来的最后一个数 } temp.insert(in[first]+1, '('); temp.insert(in[next]+1, ')'); } if(end == length) { temp.insert(end, ')'); int first = (int)(Math.random()*num); while(first == num-1) first = (int)(Math.random()*num); temp.insert(in[first]+1, '('); } ss = temp.toString(); A[iii]=ss; } } double[] K=new double[30]; double[] C=new double[30]; for(int i=0;i<30;i++) { if(t==1) { while(A[i].indexOf('(')!=-1) { int left=0; int right=A[i].length(); char op; for(int i4=0;i4 "); /* C[i]=YL.fun1(strq); B[i]=A[i].substring(0,left-1)+String.valueOf(C[i])+A[i].substring(right+1,A[i].length()-1);*/ } /*K[i]=YL.fun1(B[i]); mout.print("
");*/ } else K[i]=YL.fun1(B[i]); } for(int i=0;i<30;i++) { mout.print((i+1)+". "+A[i]); mout.print("
"); for(int i=0;i<30;i++) { mout.print((i+1)+"、"+K[i]); mout.print("
"); }}if(y==2){ for(int ii=1;ii<=x;ii++) { int a,b,c,d; String aa,bb; mout.print("30道题目"); mout.print("
"); 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