<html>
<head>
<title>月光软件站 - 编程文档 - Script - 24点终结者(javascript)</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="keywords" content="Script,24点终结者(javascript),编程,文章">
<meta name="description" content="24点终结者(javascript)">
<style>
td{font-size:9pt;line-height:140%}
body{font-size:9pt;line-height:140%}
A:link {
FONT-SIZE: 9pt; COLOR: black; TEXT-DECORATION: none
}
A:visited {
FONT-SIZE: 9pt; COLOR: black; TEXT-DECORATION: none
}
A:active {
FONT-SIZE: 9pt; COLOR: black; TEXT-DECORATION: none
}
A:hover {
FONT-SIZE: 9pt; COLOR: black; TEXT-DECORATION: underline; position: relative; left: 1px; top: 1px; clip: rect()
}
A.title
{
COLOR: blue
}
A.title:visited
{
COLOR: blue
}
</style>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF" text="#000000">
<center><script src="../top.js"></script></center>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="750">
<tr>
<td width="100%">您的位置:<a href="../">首页</a>-> <a href="index.htm">编程文档</a>-> <a href="7_1.htm">Script</a>-> 24点终结者(javascript)</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="750" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="180" valign="top">
<table bgColor="#F4F4F4" border="0" cellPadding="0" cellSpacing="0" width="165" style="border-collapse: collapse" height="100%">
<tr>
<td width="100%" valign="top">
<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr>
<td width="100%" bgcolor="#000000">
<p align="center">
<b><font color="#FFFFFF">Script</font></b></td>
</tr>
<tr>
<td width="100%"><p align="center"></td>
</tr>
<tr>
<td width="100%" bgcolor="#000000">
<p>
<img border="0" src="images/d_1.gif" align="middle" width="13" height="13"><font color="#FFFFFF"> 本类阅读TOP10</font></td>
</tr>
<tr>
<td width="100%">
·<a href="19610.htm">网站流量统计代码</a><br>·<a href="19592.htm">一个简单的javascript菜单</a><br>·<a href="19343.htm">让网页自动穿上外套</a><br>·<a href="19305.htm">在网页中控制wmplayer播放器</a><br>·<a href="19359.htm">用Javascript写的一个映射表(MAP)类--续</a><br>·<a href="19471.htm">层遇到select框时</a><br>·<a href="19355.htm">javascript表单之间的数据传递!</a><br>·<a href="19348.htm">可编辑的 HTML JavaScript 表格控件 DataGrid II</a><br>·<a href="5608.htm">3D文字特效</a><br>·<a href="2484.htm">24点终结者(javascript)</a><br>
</td>
</tr>
</table>
<br>
<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr>
<td width="100%" bgcolor="#111111">
<font color="#FFFF00">→</font>
<font color="#FFFFFF">分类导航</font></td>
</tr>
<tr>
<td width="100%"><script language=javascript src="ads/js_ads_left.js"></script></td>
</tr>
</table>
</tr>
</table>
</td>
<td width="577" valign="top" height="2">
<table border="0" cellpadding="0" cellspacing="0" style="TABLE-LAYOUT: fixed;border-collapse: collapse" width="100%">
<tr>
<td align="middle" width="100%" bgColor="#dfebf4" height="20">
<font color="#004fc6"><b>24点终结者(javascript)</b></font></td>
</tr>
<tr>
<td align="middle" width="100%" bgColor="#183EAD" height="1"></td>
</tr>
<tr>
<td width="100%" height="2"></td>
</tr>
<tr>
<td width="100%" height="38">
<p align="center"><B>作者</B>:未知 <B>来源</B>:未知 <B>加入时间</B>:2005-2-28 月光软件站</td>
</tr>
<tr>
<td width="100%" valign="top"><SCRIPT language=javaScript>
function tdisoper(f0,f1,f2,f3)
{
this[0]=f0;
this[1]=f1;
this[2]=f2;
this[3]=f3;
}
disoper=new tdisoper("-","+","/","*");
function oper(f,m,n)
{
if (f==3) return(m*n);
if (f==2) return(m/n);
if (f==1) return(parseFloat(m)+parseFloat(n));
if (f==0) return(m-n);
}
function tb(i1,i2,i4,i8)
{
this[1]=i1;
this[2]=i2;
this[4]=i4;
this[8]=i8;
}
function valid(F)
{
n=F.count1.options[F.count1.selectedIndex].value;
if (isNaN(F.a1.value)){alert("必须输入整数!"); F.a1.focus(); return(false);}
if (isNaN(F.a2.value)){alert("必须输入整数!"); F.a2.focus(); return(false);}
if (isNaN(F.a4.value)){alert("必须输入整数!"); F.a4.focus(); return(false);}
if (isNaN(F.a8.value)){alert("必须输入整数!"); F.a8.focus(); return(false);}
b=new tb(F.a1.value,F.a2.value,F.a4.value,F.a8.value);
k=0;
F.text.value="";
for (i1=1;i1<=8;i1*=2)
for (i2=1;i2<=8;i2*=2)
for (i3=1;i3<=8;i3*=2)
for (i4=1;i4<=8;i4*=2)
{
if ((i1|i2|i3|i4)!=0xf) continue;
for (f1=0;f1<=3;f1++)
for (f2=0;f2<=3;f2++)
for (f3=0;f3<=3;f3++)
{
m=oper(f3,oper(f2,oper(f1,b[i1],b[i2]) ,b[i3] ) ,b[i4]);
if (Math.abs(m-24)<1e-5 ) {
F.text.value=F.text.value+"(("+b[i1]+disoper[f1]+b[i2]+")"+disoper[f2]+b[i3]+")"+disoper[f3]+b[i4]+"\n";
if ((n!=0)&&(++k>=n)) return(false);
}
m=oper(f1, b[i1], oper(f3, oper(f2,b[i2],b[i3]) ,b[i4]) );
if (Math.abs(m-24)<1e-5){
F.text.value=F.text.value+b[i1]+disoper[f1]+"(("+b[i2]+disoper[f2]+b[i3]+")"+disoper[f3]+b[i4]+")\n";
if ((n!=0)&&(++k>=n)) return(false);
}
m=oper(f3,oper(f1,b[i1], oper(f2,b[i2],b[i3]) ),b[i4]);
if (Math.abs(m-24)<1e-5){
F.text.value=F.text.value+"("+b[i1]+disoper[f1]+"("+b[i2]+disoper[f2]+b[i3]+"))"+disoper[f3]+b[i4]+"\n";
if ((n!=0)&&(++k>=n)) return(false);
}
m=oper(f1, b[i1], oper(f2, b[i2], oper(f3, b[i3], b[i4]) ) );
if (Math.abs(m-24)<1e-5){
F.text.value=F.text.value+b[i1]+disoper[f1]+"("+b[i2]+disoper[f2]+"("+b[i3]+disoper[f3]+b[i4]+"))\n";
if ((n!=0)&&(++k>=n)) return(false);
}
m=oper(f2,oper(f1,b[i1],b[i2]), oper(f3,b[i3],b[i4]) );
if (Math.abs(m-24)<1e-5){
F.text.value=F.text.value+"("+b[i1]+disoper[f1]+b[i2]+")"+disoper[f2]+"("+b[i3]+disoper[f3]+b[i4]+")\n";
if ((n!=0)&&(++k>=n)) return(false);
}
}
}
F.text.value=F.text.value+"----END----\n"
return(false);
}
function newin(s,target,ww,hh)
{ window.open(s,target,"menubar=0,resizable=1,scrollbars=1,width="+ww+",height="+hh)}
</SCRIPT>
<FORM onsubmit="return valid(this)">请输入四个整数:<BR><INPUT maxLength=6 name=a1 size=5> <INPUT maxLength=6 name=a2 size=5> <INPUT maxLength=6 name=a4 size=5> <INPUT maxLength=6 name=a8 size=5> <SELECT name=count1> <OPTION selected value=1>只找一个答案<OPTION value=5>最多找5个<OPTION value=10>最多找10个<OPTION value=0>找全部答案</OPTION></SELECT> <BR><INPUT type=submit value=计算24点><BR>
<HR>
<TEXTAREA cols=30 name=text rows=15></TEXTAREA> </FORM>
<HR>
<FORM><INPUT onclick=history.back() type=button value=返回></FORM>
<P><A onclick="document.all.source11.style.display='block'" style="CURSOR: hand" title=点击显示源码>源码</A>
<DIV id=source11 style="BACKGROUND-COLOR: #ffffff; DISPLAY: none">
<P><SCRIPT LANGUAGE="javaScript" ><BR>function tdisoper(f0,f1,f2,f3)<BR>{<BR>this[0]=f0;<BR>this[1]=f1;<BR>this[2]=f2;<BR>this[3]=f3;<BR>}<BR>disoper=new tdisoper("-","+","/","*");</P>
<P>function oper(f,m,n)<BR>{<BR>if (f==3) return(m*n);<BR>if (f==2) return(m/n);<BR>if (f==1) return(parseFloat(m)+parseFloat(n));<BR>if (f==0) return(m-n);<BR>}</P>
<P>function tb(i1,i2,i4,i8)<BR>{<BR>this[1]=i1;<BR>this[2]=i2;<BR>this[4]=i4;<BR>this[8]=i8;<BR>}</P>
<P>function valid(F)<BR>{<BR>n=F.count1.options[F.count1.selectedIndex].value;<BR>if (isNaN(F.a1.value)){alert("必须输入整数!"); F.a1.focus(); return(false);}<BR>if (isNaN(F.a2.value)){alert("必须输入整数!"); F.a2.focus(); return(false);}<BR>if (isNaN(F.a4.value)){alert("必须输入整数!"); F.a4.focus(); return(false);}<BR>if (isNaN(F.a8.value)){alert("必须输入整数!"); F.a8.focus(); return(false);}<BR>b=new tb(F.a1.value,F.a2.value,F.a4.value,F.a8.value);<BR>k=0;<BR>F.text.value="";</P>
<P>for (i1=1;i1<=8;i1*=2)<BR> for (i2=1;i2<=8;i2*=2)<BR> for (i3=1;i3<=8;i3*=2)<BR> for (i4=1;i4<=8;i4*=2)<BR> {<BR> if ((i1|i2|i3|i4)!=0xf) continue;<BR> for (f1=0;f1<=3;f1++)<BR> for (f2=0;f2<=3;f2++)<BR> for (f3=0;f3<=3;f3++)<BR> {<BR>m=oper(f3,oper(f2,oper(f1,b[i1],b[i2]) ,b[i3] ) ,b[i4]);<BR> if (Math.abs(m-24)<1e-5 ) {<BR> F.text.value=F.text.value+"(("+b[i1]+disoper[f1]+b[i2]+")"+disoper[f2]+b[i3]+")"+disoper[f3]+b[i4]+"\n";<BR> if ((n!=0)&&(++k>=n)) return(false);<BR>}<BR>m=oper(f1, b[i1], oper(f3, oper(f2,b[i2],b[i3]) ,b[i4]) );<BR> if (Math.abs(m-24)<1e-5){<BR> F.text.value=F.text.value+b[i1]+disoper[f1]+"(("+b[i2]+disoper[f2]+b[i3]+")"+disoper[f3]+b[i4]+")\n";<BR> if ((n!=0)&&(++k>=n)) return(false);<BR>}</P>
<P>m=oper(f3,oper(f1,b[i1], oper(f2,b[i2],b[i3]) ),b[i4]);<BR> if (Math.abs(m-24)<1e-5){<BR> F.text.value=F.text.value+"("+b[i1]+disoper[f1]+"("+b[i2]+disoper[f2]+b[i3]+"))"+disoper[f3]+b[i4]+"\n";<BR> if ((n!=0)&&(++k>=n)) return(false);<BR>}</P>
<P>m=oper(f1, b[i1], oper(f2, b[i2], oper(f3, b[i3], b[i4]) ) );<BR> if (Math.abs(m-24)<1e-5){<BR> F.text.value=F.text.value+b[i1]+disoper[f1]+"("+b[i2]+disoper[f2]+"("+b[i3]+disoper[f3]+b[i4]+"))\n";<BR> if ((n!=0)&&(++k>=n)) return(false);<BR>}</P>
<P>m=oper(f2,oper(f1,b[i1],b[i2]), oper(f3,b[i3],b[i4]) );<BR> if (Math.abs(m-24)<1e-5){<BR> F.text.value=F.text.value+"("+b[i1]+disoper[f1]+b[i2]+")"+disoper[f2]+"("+b[i3]+disoper[f3]+b[i4]+")\n";<BR> if ((n!=0)&&(++k>=n)) return(false);<BR>}</P>
<P><BR> }<BR> }<BR>F.text.value=F.text.value+"----END----\n"<BR>return(false);<BR>}</P>
<P>function newin(s,target,ww,hh) <BR>{ window.open(s,target,"menubar=0,resizable=1,scrollbars=1,width="+ww+",height="+hh)}<BR></SCRIPT><BR><FORM onsubmit="return valid(this)"></P>
<P>请输入四个整数:<BR><BR><INPUT TYPE="text" NAME="a1" MAXLENGTH="6" size=5><BR><INPUT TYPE="text" NAME="a2" MAXLENGTH="6" size=5><BR><INPUT TYPE="text" NAME="a4" MAXLENGTH="6" size=5><BR><INPUT TYPE="text" NAME="a8" MAXLENGTH="6" size=5></P>
<P><SELECT NAME="count1" > <BR><OPTION VALUE="1" selected=on> 只找一个答案<BR><OPTION VALUE="5" > 最多找5个<BR><OPTION VALUE=10 > 最多找10个<BR><OPTION VALUE=0 > 找全部答案<BR></select><BR><BR><BR> <INPUT TYPE=submit VALUE="计算24点"><BR><BR><HR><BR><TEXTAREA NAME="text" ROWS="15" COLS="30"></TEXTAREA><BR></FORM><BR><HR><BR><FORM><INPUT TYPE="button" VALUE="返回" onClick="history.back()"></FORM></P>
<P> </P></DIV><img border="0" src="down_info.asp?id=2484" width="1" height="1"><br><br></td>
</tr>
<tr>
<td width="100%" bgcolor="#CCCCCC" height="1"></td>
</tr>
<tr>
<td width="100%"><br><b>相关文章</b>:<p><b>相关软件</b>:</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
<center><script src="../bottom.js"></script></center>
</body>
</html><P></P><P></P>
<DIV ALIGN="center"><CENTER>
<TABLE cellSpacing="0" cellPadding="0" WIDTH="94%" style="font-size: 9pt;" >
<TR><TD WIDTH="94%" bgColor="#000000" HEIGHT="1"></TD></TR>
<TR><TD WIDTH="94%" HEIGHT="5"></TD></TR>
<TR>
<TD ALIGN="middle" WIDTH="94%">
<A HREF="/" TARGET="_top">月光软件</A>┊<A HREF="/download/" TARGET="_top">程序下载</A>┊<A HREF="/doc/" TARGET="_top">编程文档</A>┊<A HREF="/book/" TARGET="_top">电脑教程</A>┊<A HREF="/web/" TARGET="_top">网站设计</A>┊<A HREF="/site/" TARGET="_top">网址导航</A>┊<A HREF="/art/" TARGET="_top">网络文学</A>┊<A HREF="/game/" TARGET="_top">游戏天地</A>┊<A HREF="/joke/" TARGET="_top">幽默笑话</A>┊<A href="/life/" target="_top">生活休闲</A>┊<A HREF="/link/" target="_top">友情链接</A>┊<A HREF="/guestbook/" TARGET="_top">给我留言</A><BR>
<a href="/program/doc/docelite1105.htm">电脑技术</a>┊<a href="/program/doc/docelite405353.htm">编程开发</a>┊<a href="/program/doc/docelite25188.htm">网络专区</a>┊<a href="/program/doc/docelite10811.htm">谈天说地</a>┊<a href="/program/doc/docelite113108.htm">情感世界</a>┊<a href="/program/doc/docelite872697.htm">游戏元素</a>┊<a href="/program/doc/docelite50820.htm">分类游戏</a>┊<a href="/program/doc/docelite166458.htm">热门游戏</a>┊<a href="/program/doc/docelite42994.htm">体育运动</a>┊<a href="/program/doc/docelite872698.htm">手机专区</a>┊<a href="/program/doc/docelite28075.htm">业余爱好</a>┊<a href="/program/doc/docelite34403.htm">影视沙龙</a>
<br>
<a href="/program/doc/docelite872701.htm">音乐天地</a>┊<a href="/program/doc/docelite872702.htm">数码广场</a>┊<a href="/program/doc/docelite121902.htm">教育园地</a>┊<a href="/program/doc/docelite872703.htm">科学大观</a>┊<a href="/program/doc/docelite991826.htm">古今纵横</a>┊<a href="/program/doc/docelite49868.htm">谈股论金</a>┊<a href="/program/doc/docelite55064.htm">人文艺术</a>┊<a href="/program/doc/docelite165391.htm">医学保健</a>┊<a href="/program/doc/docelite115338.htm">动漫图酷</a>┊<a href="/program/doc/docelite872704.htm">二手专区</a>┊<a href="/program/doc/docelite112364.htm">地方风情</a>┊<a href="/program/doc/docelite165368.htm">各行各业</a>
<BR><BR>
<A HREF="http://www.moon-soft.com/">月光软件站</A>·<A HREF="/sitemap.htm" target="_blank">版权所有</A>
</TD></TR>
</TABLE>
</CENTER></DIV>
<!-- */ //-->
来源:https://www.cnblogs.com/austinleng/archive/2005/04/21/142696.html