<html>
<head>
<title>Giai phuong trinh bac 2</title>
<script language="JavaScript">
function giai(form){
var x1,x2;
var x,y,z,delta;
x= parseInt(form.a.value);
y= parseInt(form.b.value);
z= parseInt(form.c.value);
delta=(y*y-4*x*z)
if(delta ==0){
alert("phuong trinh co nghiem kep");
x1=-y/(2*x) ;
x2=-y/(2*x);
form.x.value=eval(x1);
form.y.value=eval(x2);
}
else if(delta<0){
alert("phuong trinh vo nghiem");
}
else{
alert("phuong trinh co hai nghiem");
x1=(-y-Math.sqrt(delta))/(2*x);
x2=(-y+Math.sqrt(delta))/(2*x);
form.x.value=eval(x1);
form.y.value=eval(x2);
}
}
</script>
</head>
<body>
<form method="post">
<center>
<br>Nhap gia tri a:
<input type="text" name="a" value="">
<br> Nhap gia tri b:
<input type="text" name="b" value="">
<br>Nhap gia tri c:
<input type="text" name="c" value="">
<br>Đáp số:
<input type="text" name="x" value="">
<input type="text" name="y" value="">
<input type="button" value="giai" onClick="giai(this.form)">
</center>
</form>
</body>
</html>
{ 0 nhận xét... read them below or add one }
Đăng nhận xét