日期:2014-05-16 浏览次数:20455 次
function rnd(min,max){
var tmp=min;
if(max<min){min=max;max=tmp;}
return Math.floor(Math.random()*(max-min+1)+min);
}
function getTopic(){
if(num>10){alert('已经做了10题鸟~~');return false;}
num++;
var idx=rnd(0,topics.length-1);
return topics.splice(idx,1)//从题目中删除当前的项,遮掩高就不会出现重复题目了,并返回当前删除的项以便匹配
}
var topics=[
["判断:1+1=2","对","说明:他就是等于2"],
["判断:2+2=2","错","说明:他就是等于4"],
["判断:3+3=2","错","说明:他就是等于6"],
["判断:4+4=2","错","说明:他就是等于8"],
["判断:5+5=2","错","说明:他就是等于10"],
["判断:6+6=2","错","说明:他就是等于12"],
["判断:7+7=2","错","说明:他就是等于14"],
["判断:8+8=2","错","说明:他就是等于16"],
["判断:9+9=2","错","说明:他就是等于18"],
["判断:10+10=2","错","说明:他就是等于20"]
];
var num=1;
alert(getTopic());alert(getTopic());alert(getTopic());;alert(getTopic());alert(getTopic())
alert(getTopic());alert(getTopic());alert(getTopic());;alert(getTopic());alert(getTopic())
alert(getTopic())//false