2Hi.Biz
Trang chủ | TWIG | Xtscript | Templates | Xtgem
Share code giải phương trình bậc nhất và bậc hai cho wap xtgem và html | Share code | Xtgem - 2Hi.Biz
▼ Share code giải phương trình bậc nhất và bậc hai cho wap xtgem và html
* NVGT
- Cấp bậc: mem
27-03-2015
CODE GIẢI PHƯƠNG TRÌNH BẬC NHẤT
<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>

-Code giải phươg trình bậc hai:
<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>
1 người thích điều này!
* MT-A
- Cấp bậc: mem
27-03-2015
đếu hiểu...:DD
* Pupy
- Cấp bậc: admin
27-03-2015
Cho vào phần tiện ích ở wap cũng đc đó xi
* NVGT
- Cấp bậc: mem
28-03-2015
* MT-A Bạn dán code vào nơi cần hiển thị là được nhé.
▲ Tổng số: 4
- Share:
BBCode:

Link:
Online: Guests: 1

Từ khóa: code , html , nhất , wap , và