***综合类***二元一次方程的解答程序
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件要完成此效果需要两个步骤
第一步:把如下代码加入到<head>区域中
<script language="javascript">
<!-- begin
var rootparti;
var rootpart;
var det;
var rootparti1;
var rootparti2;
var a;
var b;
var c;
var x1;
var x2;
var i = "i";
function checkquad() {
var a = document.fquad.fa.value;
var b = document.fquad.fb.value;
var c = document.fquad.fc.value;
if (a == 0 && c != 0) {
x1 = -c / b;
x2 = "not a quadratic equation, but here is your answer for x";
document.fquad.x1.value=x1;
document.fquad.x2.value=x2;
}
else if (a == "" && c != 0) {
x1 = -c / b;
x2 = "not a quadratic equation";
document.fquad.x1.value=x1;
document.fquad.x2.value=x2;
}
else {
quad();
}
}
function quad() {
var a = document.fquad.fa.value;
var b = document.fquad.fb.value;
var c = document.fquad.fc.value;
det = math.pow(b,2) - 4 * a * c;
rootpart = math.sqrt(det) / (2 * a);
rootparti = (math.sqrt(-det) / (2 * a)) + i;
if (parsefloat(rootparti) < 0) {
rootparti1 = rootparti;
rootparti2 = (-1 * parsefloat(rootparti)) + i;
}
else {
rootparti1 = (-1 * parsefloat(rootparti)) + i;
rootparti2 = rootparti;
}
if (rootparti1 == "1i") {
rootparti1 = i;
rootparti2 = "-i";
}
else if (rootparti1 == "-1i") {
rootparti1 = "-i";
rootparti2 = i;
}
if (det == 0) {
x1 = x2 = -b / (2 * a);
}
else if (det > 0) {
x1 = (-b + math.sqrt(det)) / (2 * a);
x2 = (-b - math.sqrt(det)) / (2 * a);
}
else if ((-b / (2 * a)) == 0) {
x1 = rootparti1;
x2 = rootparti2;
}
else {
x1 = (-b / (2 * a) + " + " + rootparti1);
x2 = (-b / (2 * a) + " + " + rootparti2);
}
document.fquad.x1.value=x1;
document.fquad.x2.value=x2;
}
//end -->
</script>
第二步:把如下代码加入到<body>区域中
<form name=fquad>
<table align="center">
<tr>
<td>
<h2>
<input name=fa size=4>
<font color="#33ff33">x<sup>2</sup>+</font>
<input name=fb size=4>
<font color="#33ff33"> x +</font>
<input name=fc size=4>
<font color="#33ff33">= 0</font>
<input type=button value="求值" onclick="checkquad()">
<input type=reset value="重填">
</h2>
</td>
</tr>
<tr>
<td>
<h2> <font color="#33ff33">x<sub>1</sub>=</font>
<input name=x1 size=45>
<br>
<font color="#33ff33">x<sub>2</sub>= </font>
<input name=x2 size=45>
</h2>
</td>
</tr>
</table>
</form>
--------------------------------------
拥有三人行论坛管理系列软件,一个人就可以管理一个论坛的更新维护。还能使您的论坛有千人在线的真实火暴效果,让您不在为论坛因没有人气而留不住会员而烦恼,使您的论坛早日成为一流的论坛。详情请登陆网站:http://www.cnsrx.cn 三人行论坛管理软件,站长必备的专业好工具。(您使用的是免费版本,购买收费版本后,将不带广告。业务QQ:247216 44985227)
页:
[1]