<html><head>
<script language="javascript">
var inte=new Array(4);
var str1='';
var str2='';
var str=new Array(4);
var counter=0;
function beginning(){
inte[0]=Math.random()*10;
inte[0]=Math.floor(inte[0]);
inte[1]=Math.random()*10;
inte[1]=Math.floor(inte[1]);
while(inte[1]==inte[0])
{
inte[1]=Math.random()*10;
inte[1]=Math.floor(inte[1]);
}
inte[2]=Math.random()*10;
inte[2]=Math.floor(inte[2]);
while(inte[2]==inte[0] || inte[2]==inte[1])
{
inte[2]=Math.random()*10;
inte[2]=Math.floor(inte[2]);
}
inte[3]=Math.random()*10;
inte[3]=Math.floor(inte[3]);
while(inte[3]==inte[0] || inte[3]==inte[1] || inte[3]==inte[2])
{
inte[3]=Math.random()*10;
inte[3]=Math.floor(inte[3]);
}
}
function getvalues(obj){
str1=obj.outtext.value;
document.In.comment.value+=str1;
document.In.comment.value+='\n';
str[0]=str1.charAt(0);
str[1]=str1.charAt(1);
str[2]=str1.charAt(2);
str[3]=str1.charAt(3);
counter++;
var k=0,l=0;
var i,j;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
{
if(eval(str[i]))==inte[j])
{
if(i==j)
k++;
else
l++;
}
}
str2=k+"A";
document.In.comment.value+=str2;
str2=l+"B";
document.In.comment.value+=str2;
document.In.comment.value+='\n';
if(k==4)
{
alert("恭喜您猜对了!");
}
if(counter>=8)
alert("sorry,you are failed!");
document.In.outtext.value='';
}
function key(){
alert("标准答案是"+inte[0]+inte[1]+inte[2]+inte[3]);
}
function restart()
{
beginning();
document.In.comment.value='';
document.In.outtext.value='';
counter=0;
}
</script>
<style type="text/css">
<!--
.STYLE1 {font-size: xx-large}
#Layer1 {
position:absolute;
left:16px;
top:7px;
width:185px;
height:152px;
z-index:1;
}
#Layer2 {
position:absolute;
left:583px;
top:377px;
width:170px;
height:166px;
z-index:2;
}
#Layer3 {
position:absolute;
left:218px;
top:257px;
width:171px;
height:158px;
z-index:3;
}
#Layer4 {
position:absolute;
left:1149px;
top:21px;
width:133px;
height:140px;
z-index:4;
}
#Layer5 {
position:absolute;
left:985px;
top:226px;
width:168px;
height:156px;
z-index:5;
}
#Layer6 {
position:absolute;
left:829px;
top:42px;
width:186px;
height:163px;
z-index:6;
}
#Layer7 {
position:absolute;
left:18px;
top:416px;
width:1274px;
height:4px;
z-index:6;
}
#Layer8 {
position:absolute;
left:51px;
top:487px;
width:199px;
height:165px;
z-index:6;
}
#Layer9 {
position:absolute;
left:260px;
top:509px;
width:672px;
height:191px;
z-index:7;
}
.STYLE2 {
font-size: 12px;
color: #3300FF;
}
#Layer10 {
position:absolute;
left:354px;
top:556px;
width:746px;
height:30px;
z-index:8;
}
.STYLE5 {color: #2096FF}
.STYLE7 {font-size: 36px; color: #660033; }
#Layer11 {
position:absolute;
left:448px;
top:68px;
width:109px;
height:15px;
z-index:8;
}
.STYLE8 {font-size: 12px}
-->
</style>
<title>猜数字游戏</title></head>
</html>
<body onLoad="beginning()">
<div id="Layer8">
<p class="STYLE7"> </p>
<p class="STYLE7">游戏说明:</p>
</div>
<div class="STYLE8" id="Layer11">
<div align="center">输入您的答案</div>
</div>
<p align="left" class="STYLE1">猜数字游戏
<form name="In">
<div align="center">
<input type="text" value="" name="outtext" maxlength="4">
<br>
<input type="button" value="提交" onClick="getvalues(this.form)">
<br>
<textarea name="comment" rows="20" ></textarea>
<br>
<input type="button" value="查看答案" onClick="key()">
<input type="button" value="重新开始" onClick="restart()">
<br>
</p>
</div>
<div class="STYLE5" id="Layer9">
<p class="STYLE2"> 每次系统抽取0-9之间的4个不重复随机数,你将有8次机会进行猜测。</p>
<p class="STYLE2">如果您输入的数字和系统的数字完全一致,您就成功了!</p>
<p class="STYLE2">如果您给出的答案中某个数字和系统答案的某数字位置一样,那么您将得到一个A,有几个一样,您就得到几A;</p>
<p class="STYLE2">如果您给出答案的数字和系统答案中其他位置的数字一样,那么您将得到一个B,有几个一样,您就得到几个B</p>
<p class="STYLE2">例如系统答案是1357,而您给出的答案是1467,那么在文本域给您的提示将是“2A2B”</p>
</div>
</body>
没有合适的资源?快使用搜索试试~ 我知道了~
guest_number.rar_guest number_猜数字游戏
共2个文件
html:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 120 浏览量
2022-09-14
20:02:11
上传
评论
收藏 3KB RAR 举报
温馨提示
实现了猜数字游戏,规则:输入一个4位数,猜测,然后给出提示(0A3B)
资源推荐
资源详情
资源评论
收起资源包目录
guest_number.rar (2个子文件)
猜数字
猜数字游戏.html 4KB
猜数字.html 4KB
共 2 条
- 1
资源评论
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 笔记实验六,spark,大数据分析
- ####蓝桥杯python的详细的信息介绍
- 电子万年历软件仿真(经过多次修改,保证正确性)
- Unity XR 手势射击控制脚本(适用于任何可手势识别的设备)
- 机械设计全自动电表(NB和IC卡表)控制和上壳装配线sw16可编辑非常好的设计图纸100%好用.zip
- 基于matlab的EAN-13条形码识别系统GUI界面.zip代码53
- matlab基于bp神经网络交通信号标志识别GUI界面13个标志.zip代码54
- 电子万年历答辩实物展示视频mp4格式
- 基于python实现的程序,包括哈希感知算法cvHash,图像切割cvsplit,固定目标检测cvRec(附文档ppt)等
- 计算0-10000之间所有偶数的和
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功