代码如下

var a = dialogs.input("请输入二次项系数");
var b = dialogs.input("请输入一次项系数");
var c = dialogs.input("请输入常数项");
var B = Math.pow(b, 2);
var Ac = a * c;
var AC = Ac * 4;
var derta = B - AC;
if (derta < 0) {
alert("运算结果", "X无实数解");
} else {
var squareroot = Math.pow(derta, 0.5);
var b_xiang_fan_shu = b * -1;
var gen_hao_shang = b_xiang_fan_shu + squareroot;
var gen_hao_shang2 = b_xiang_fan_shu - squareroot;
var gen_hao_xia = 2 * a;
var gen1 = gen_hao_shang / gen_hao_xia;
var gen2 = gen_hao_shang2 / gen_hao_xia;
var abc1 = "X1=" + gen1;
var abc2 = " X2=" + gen2
var jie = abc1 + abc2
alert("根", jie);
};