By GokiSoft.com|
19:32 23/10/2023|
Học JS
Giải phương trình bậc nhất bằng Javascript BT1605
Cho phương trình bậc nhất như sau
a*x + b= 0
Với a, b là số nguyên => tạo ngẫu nhiên
Hiển thị kết quả của x ra màn hình
Tags:
Liên kết rút gọn:
Bình luận
Đức Sơn [T2008A]2020-10-14 13:47:02 |
#PTBT.html
<!DOCTYPE html>
<html>
<head>
<title>Pt bậc nhất JS</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var a=prompt("Nhap gia tri a:");
var b=prompt("Nhap gia tri b:");
var x= -b/a;
if(a==0) {
if(b==0) {
document.write("phuong trinh vo so nghiem");
}
else {
document.write("phuong trinh vo nghiem");
}
}
else {
document.write(x);
}
</script>
</body>
</html>
Nguyên Phấn Đông [T2008A]2020-10-14 10:05:14 |
<!DOCTYPE html>
<html>
<head>
<title>Tim x</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var a= prompt('Nhap A:')
var b= prompt('Nhap B:')
if (a == 0 ){
if (b == 0) {
document.write('Phuong trinh vo so nghiem')
}
else document.write('Phuong trinh vo nghiem')
}
else {
x= -b/a
document.write(x)
}
</script>
</body>
</html>
Nguyễn Hữu Hiếu [T2008A]2020-10-14 09:47:11 |
#1605.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
var a = prompt("Nhap a = ", 0);
var b = prompt("Nhap a = ", 0);
var x = -b/a;
if (a == 0) {
if (b == 0) {
document.write("PT vo so nghiem");
}
else {
document.write("PT vo nghiem");
}
}
else {
document.write(x);
}
</script>
</body>
</html>
Đặng Trần Nhật Minh [T2008A]2020-10-14 09:35:27 |
#Bai3.html
<!DOCTYPE html>
<html>
<head>
<title>Bai 3</title>
</head>
<body>
<script type="text/javascript">
var a = prompt("Input a: ");
var b = prompt("Input b: ");
if (a === 0) {
if (b === 0) alert("The Equation Has Infinite Solution.\n");
else alert("The Equation Has No Solution.\n");
}
else {
if (b == 0) alert("The Equation Has Infinite Solution.\n");
else {
var x = -b / a;
alert("The Equation Has 1 Solution x = " + x);
}
}
</script>
</body>
</html>