📄 acc_bdsjsq.php
字号:
<td width="50">
<input type="button" name="1/2" value="1/2" onClick="form.input.value += '0.5'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/3" value="1/3" onClick="form.input.value += '0.3333333333'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/4" value="1/4" onClick="form.input.value += '0.25'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
</tr>
<tr bgcolor="#000000">
<td width="50">
<input type="button" name="sin" value="sin" onClick="Sin()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="cos" value="cos" onClick="Cos()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="tan" value="tan" onClick="Tan()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="20"> </td>
<td width="50">
<input type="button" name="1/5" value="1/5" onClick="form.input.value += '0.2'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/6" value="1/6" onClick="form.input.value += '0.1666666667'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/7" value="1/7" onClick="form.input.value += '0.1428571429'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
</tr>
<tr bgcolor="#000000">
<td width="50">
<input type="button" name="sin2" value="asin" onClick="Isin()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="cos2" value="acos" onClick="Icos()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="tan2" value="atan" onClick="Itan()" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="20"> </td>
<td width="50">
<input type="button" name="1/8" value="1/8" onClick="form.input.value += '0.125'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/9" value="1/9" onClick="form.input.value += '0.1111111111'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50">
<input type="button" name="1/10" value="1/10" onClick="form.input.value += '0.1'" style="COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
</tr>
</table>
</form>
</div>
<hr style="color:#0000ff;width:329px;height:4px;" />
<center>
<script language='javascript'>
function js() {
document.getElementById("jg0").value = eval(document.getElementById("bds0").value);
}
</script>
(表达式计算器)请输入表达式:<br />
<input type='text' name='bds0' id='bds0' size='60' onchange='javascript:js();' />
<br /><input type='button' name='jg' value='计算结果:' onclick='this.blur();' />
<input type='button' name='jg0' id='jg0' size='20' value=' ' onclick='this.blur();' readonly />
</center>
<hr style="color:#f83;width:439px;height:6px;" />
<script language="javascript">
var fuhao=new Array(); //用来存放运算符号
function jisuan() {
var x, y, z, i, j, k, r, f;//定义循环变量
var number=new Array();//用来存放用户输入的4个数字
var fanhui;//接受函数的返回值
var pan, v1, v2, v3, v4;//判断用户的输入
//运算符号初始化
fuhao[0]="+";
fuhao[1]="-";
fuhao[2]="*";
fuhao[3]="/";
//判断用户的输入是否为数字
v1=fuc(document.all.t0.value);
v2=fuc(document.all.t1.value);
v3=fuc(document.all.t2.value);
v4=fuc(document.all.t3.value);
pan=v1+v2+v3+v4;
if(pan!==4) {
alert("请输入数字!");
return;
}
//用户输入的值初始化
for(r=0;r<4;r++) {
number[r]=document.all('t'+r).value;
}
//运算符号的组合有4*4*4=64种
for(i=0;i<4;i++) {
for(j=0;j<4;j++) {
for(k=0;k<4;k++) {
//数字的组合有4!=24种,构成4个数字的全排列
for(x=0;x<4;x++) {
for(y=0;y<4;y++) {
if(x==y) {
continue;
} else {
for(z=0;z<4;z++) {
if(z==x || z==y) {
continue
} else {
for(f=0;f<4;f++) {
if(f==x || f==y || f==z) {
continue
}else{
fanhui=sz(number[x], number[y], number[z], number[f], i, j, k);
if(fanhui==1) {
return;
} else {
document.all.result.value="这4个数字无解";
}
}
}
}
}
}
}
}
}
}
}
}
function sz(a, b, c, d, i, j, k) {
var shizi=new Array();//存放表达式
var s;
var result;
//初始化组合表达式
shizi[0]=a+fuhao[i]+b+fuhao[j]+c+fuhao[k]+d; //表达式(1) a?b?c?d
shizi[1]="("+a+fuhao[i]+b+")"+fuhao[j]+c+fuhao[k]+d; //表达式(2) (a?b)?c?d
shizi[2]=a+fuhao[i]+"("+b+fuhao[j]+c+")"+fuhao[k]+d; //表达式(3) a?(b?c)?d
shizi[3]=a+fuhao[i]+b+fuhao[j]+"("+c+fuhao[k]+d+")"; //表达式(4) a?b?(c?d)
shizi[4]="(("+a+fuhao[i]+b+")"+fuhao[j]+c+")"+fuhao[k]+d; //表达式(5) ((a?b)?c)?d
shizi[5]="("+a+fuhao[i]+"("+b+fuhao[j]+c+"))"+fuhao[k]+d; //表达式(6) (a?(b?c))?d
shizi[6]=a+fuhao[i]+"(("+b+fuhao[j]+c+")"+fuhao[k]+d+")"; //表达式(7) a?((b?c)?d)
shizi[7]=a+fuhao[i]+"("+b+fuhao[j]+"("+c+fuhao[k]+d+"))"; //表达式(8) a?(b?(c?d))
shizi[8]="("+a+fuhao[i]+b+")"+fuhao[j]+"("+c+fuhao[k]+d+")"; //表达式(9) (a?b)?(c?d)
//检测结果,如果为24,返回1
for(s=0;s<9;s++) {
result=eval(shizi[s]);
if(result==24) {
document.all.result.value=shizi[s]+"=24";
return 1;
}
}
}
//检测是否输入数字函数
function fuc(n) {
var text;
var l;
text="0123456789"
if(n.length==0) {
return 0;
}
for(l=0;l<=n.length;l++) {
if(text.indexOf(n.charAt(l))!=-1) {
return 1;
} else {
return 0;
}
}
}
</script>
<center>
<table width="370">
<tr><th colspan="4">24点游戏::请输入四个数</th></tr>
<tr><th>1</th><th>2</th><th>3</th><th>4</th></tr>
<tr>
<td align="center"><input type="text" size="8" name="t0"></td>
<td align="center"><input type="text" size="8" name="t1"></td>
<td align="center"><input type="text" size="8" name="t2"></td>
<td align="center"><input type="text" size="8" name="t3"></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="button" name="jisuan" value="计算结果:" onclick="javascript:jisuan();">
<input type="text" size="34" name="result" readonly>
</td>
</tr>
</table>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -