用jsp实现下面这个小游戏。游戏开始时,从0-9中随机抽取4个数字让玩家猜。当玩家给出一个猜测时,

& lt% @ page language = " Java " import = " Java . util . * " page encoding = " utf-8 " % & gt;

& lthtml & gt

& lthead & gt

& ltscript type = " text/JavaScript " & gt;

函数与(id) {

//:获取输入框的值。

var num 1 = document . getelementbyid(' one ')。价值;

var num 2 = document . getelementbyid(' two ')。价值;

var num 3 = document . getelementbyid(' three ')。价值;

var num 4 = document . getelementbyid(' four ')。价值;

//:获取随机数

var numa = document . getelementbyid(' 1 ')。价值;

var number = document . getelementbyid(' 2 ')。价值;

var numc = document . getelementbyid(' 3 ')。价值;

var numd = document . getelementbyid(' 4 ')。价值;

开关(id) {

案例'一':

if (num1 == numa) {

Alert('数字1正确:'+num 1);

} else if(num 1 & gt;numa) {

Alert('输入第1位数字。“大!”);

} else if(num 1 & lt;numa) {

Alert('输入第1位数字。“小!”);

}

打破;

}

案例'二':

if(num 2 = = num){

Alert('第二位数字正确:'+num 2);

} else if(num 2 & gt;编号){

Alert('第二位数字输入。“大!”);

} else if(num 2 & lt;编号){

Alert('第二位数字输入。“小!”);

}

打破;

}

案例‘三’:

if (num3 == numc) {

Alert('第三位数字正确'+num 3);

} else if(num 3 & gt;numc) {

Alert('输入第三个数字。“它很大!”);

} else if(num 3 & lt;numc) {

Alert('输入第三个数字。“小!”);

}

打破;

}

案例'四':

if (num4 == numd) {

Alert('第四位数字正确'+num 4);

} else if(num 4 & gt;numd) {

Alert('输入第四个数字。“它很大!”);

} else if(num 4 & lt;numd) {

Alert('输入第四个数字。“小!”);

}

打破;

}

}

if(num 4 = = numd & amp;& ampnum3 = = numc & amp& ampnum2 = = numb & amp& ampnum1 == numa ) {

文档。getelementbyid ('nums ')。innertext = ' Random result:'+num 1+' '+num 2。

+' '+num 3+' '+num 4;

文档。getelementbyid ('result ')。innertext = '用户结果:'+numa+' '

+num+' '+numc+' '+numd;

}

}

& lt/script & gt;

& lt/head & gt;

& ltbody & gt

& lt%

int[]nums = new int[4];

//生成随机数

for(int I = 0;我& lt4;i++) {

nums[I]=(int)(math . random()* 10);

}

% & gt

& lt表单操作= " " & gt

& lt%

for(int j = 0;j & ltnums.lengthj++) {

% & gt

& lt输入type = " hidden " id = " & lt%=j + 1% >value = " & lt%=nums[j]% >& gt

& lt%

}

% & gt

& lt表& gt

& lttr & gt

& ltTD colspan = " 4 " align = " center " hight = " 10 " >

猜谜游戏

& lt/TD & gt;

& lt/tr & gt;

& lttr & gt

& lttd & gt

第一个数字

& lt/TD & gt;

& lttd & gt

第二个数字

& lt/TD & gt;

& lttd & gt

第三个数字

& lt/TD & gt;

& lttd & gt

第四个数字

& lt/TD & gt;

& lt/tr & gt;

& lttr & gt

& lttd & gt

& ltinput id = " one " type = " text " size = " 5 " >

& lt/TD & gt;

& lttd & gt

& ltinput id = " two " type = " text " size = " 5 " >

& lt/TD & gt;

& lttd & gt

& ltinput id = " three " type = " text " size = " 5 " >

& lt/TD & gt;

& lttd & gt

& ltinput id = " four " type = " text " size = " 5 " >

& lt/TD & gt;

& lt/tr & gt;

& lttr & gt

& lttd colspan="4" hight="10 " >

& ltdiv id = " nums " & gt& lt/div & gt;

& lt/TD & gt;

& lt/tr & gt;

& lttr & gt

& lttd colspan="4" hight="10 " >

& ltdiv id = " result " & gt& ltinput type = " button " value = " submit " onclick = " vs(' one ')、vs ('two ')、vs ('three ')、vs(' four ')" > & lt;/div & gt;

& lt/TD & gt;

& lt/tr & gt;

& lt/table & gt;

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;