html的。 ====================== <!DOCTYPE HTML> <html> <head> <title>Untitled</title> </head> <body> <div> 题目数:<select id="count" onchange="countChange()"> <options> <option value="">选择出题数</option> <option value="10">10题</option> <option value="20">20题</option> <option value="50">50题</option> </options> </select> </div> <div > <ol id="questionDiv"> </ol> </div> <div > <input type="button" id="submit" value="交卷" onclick="doSubmit()"></input> <input type="button" id="re" value="重新答题" onclick="re()"></input> </div> <div id="score"> </div> <script type="text/javascript"> var qDiv = document.getElementById("questionDiv"); var cSelect = document.getElementById("count"); var startTime; function countChange(){ var html=""; for(var i=0;i<event.target.value;i++){ var op = Math.round(Math.random()*4-0.5); var left = Math.round(Math.random()*100-0.5); var right = Math.round(Math.random()*100-0.5); if(op==0){ html +="<li>" + (Math.max(left,right) - Math.min(left,right)) + " + "+ Math.min(left,right) + " = <input type='text' name='q'></input><input type='hidden' name='a' value='" + ((Math.max(left,right) - Math.min(left,right)) + Math.min(left,right)) +"'></input></li>"; }else if(op==1){ html +="<li>" + Math.max(left,right) + " - "+ Math.min(left,right) + " = <input type='text' name='q'></input><input type='hidden'name='a' value='" + (Math.max(left,right) - Math.min(left,right)) +"'></input></li>"; }else if(op==2){ html +="<li>" + Math.max(Math.round(left/10),1) + " × " + Math.max(Math.round(right/10),1) + " = <input type='text' name='q'></input><input type='hidden' name='a' value='" + (Math.max(Math.round(left/10),1) * Math.max(Math.round(right/10),1)) +"'></input></li>"; }else if(op==3){ html +="<li>" + Math.max(Math.round(left/10),1) * Math.max(Math.round(right/10),1) + " ÷ " + Math.max(Math.round(left/10),1) + " = <input type='text' name='q'></input><input type='hidden' name='a' value='" + (Math.max(Math.round(left/10),1) * Math.max(Math.round(right/10),1) / Math.max(Math.round(left/10),1)) +"'></input></li>"; } } qDiv.innerHTML=html; startTime = new Date().getTime(); } function doSubmit(){ var q = document.getElementsByName("q"),a=document.getElementsByName("a"); var score = 0; var scoreA = 100/cSelect.value for(var i =0;i<q.length;i++){ if(q[i].value==a[i].value){ score +=scoreA; } } var time = Math.round((new Date().getTime() - startTime)/60000-0.5); var time2 = Math.round((new Date().getTime() - startTime)%60000/1000); if(score == 100){ alert("恭喜用时:" + time + "分" + time2 + "秒全部答对"); }else{ alert("用时:" + time + "分" + time2 + "秒\n得分:" +score ); } } function re(){ qDiv.innerHTML=""; cSelect.value= ""; } </script> </body> </html>
给你个思路吧 1、首先随机生成加减乘除其中的一个符号(查查怎么随机) 2、随机生成两个数字,用上面的符号拼接 3、程序检查下计算结果是否符合范围,不符合就重新随生成两个数字,符合范围就打印输出,等做题的人录入。 4、计算的结果范围:0-100,不能包含小数,除数不能为0等等
打个标签,估计没人理你。
public static void main(String []args) { System.out.println("这是一个小学算术运算测试程序"); }
50,528
社区成员
85,607
社区内容
加载中
试试用AI创作助手写篇文章吧