• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Share code giải phương trình bậc nhất và bậc hai cho xtgem và wap html

Admin

Well-Known Member
Staff member
Administrator
Giải phương trình bậc nhất:
HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Hệ số a</title>
<script type="text/javascript" language="javascript">
function pt()
{
var a,b,x;
a = document.nhap.a.value;
b = document.nhap.b.value;
if (a==0 && b==0)
{
document.write("Phuong trinh co vo so nghiem");
}
else if(a==0 && b!==0)
{
document.write("Phuong trinh vo nghiem");
}
else if(a!=0 && b!=0)
{
x= -b/a;
document.nhap.c.value =x;
}
}
</script>
</head>
<body>
<form name="nhap">
he so a:
<input type="text" name="a">
<p>he so b:
<input type="text" name="b">
</p>
<p>ket qua:
<label>
<input type="text" name="c">
</label>
</p>
<p>
<input type="button" value="giai" onClick="pt()">
</p>
</form>
</body>
</html>
-Giải phươg trình bậc hai:
HTML:
<script type="text/javascript" language="javascript">
function ptbh()
{
var a, b, c, delta, x, x1, x2;
a = document.nhap.a.value;
b = document.nhap.b.value;
c = document.nhap.c.value;
delta = b*b - 4*a*c;
if (delta < 0)
{
document.write(" Phương trình vô nghiệm ");
}
else if (delta ==0)
{
x = -b/2*a;
document.nhap.f.value =x;
}
else if (delta > 0)
{
x1 = (-b + Math.sqrt(delta))/(2*a);
document.nhap.d.value =x1;
x2 = (-b - Math.sqrt(delta))/(2*a);
document.nhap.e.value =x2;
}
}
</script>
</head>
<body>
<form name="nhap">
<p>Nhap a:
<input name="a" type="text" />
x1:
<label>
<input type="text" name="d" />
</label>
</p>
<p>Nhập b:
<label>
<input type="text" name="b" />
</label>
x2:
<label>
<input type="text" name="e"/>
</label>
</p>
<p>Nhập c:
<label>
<input type="text" name="c"/>
</label>
Nghiệm kép:
<label>
<input type="text" name="f" />
</label>
</p>
<p>
<label>
<input type="button" value="giai" onclick="ptbh()" />
<input type="button" value="reset" onclick="location.href='ptbh.htm'" />
</label>
</p>
</form>
</body>
</html>
 

Facebook Comments

New posts New threads New resources

Back
Top