在线一元二次方程计算器实例
的有关信息介绍如下:在线一元二次方程式计算器360问答实例分享,大家参考使用吧
代码如下:<html><head><metahttp-equiv诉内电反表频变十林胡="Content-Type"content="text/html"charset="utf-8"><t硫金鲁句气见itle>在线一元二次方程式计算器</title></head><body><formname="fquad"> <palign="center">解二次方程式计算<br> </p> <tablealign充树步钢红减="center"> <tbody> <tr> <tdbgcolor="#990000"> <h灯攻端社抗席消光2><fontcolor="#ffffff"><inputsize="4"name="fa"type="text">x<sup>2</sup>+<inputs八电物孔为般务件斗众ize="4"name="fb"type="tex原素黑伯限穿固名t">x+<inpu前起于唱tsize="4"name="fc"type="text">=0<inputonclick="checkQuad()"type="button"value="解题"><inputtype="reset"value="重置"></font></h2> <p><fontcolor="#ffffff"face="Arial"><b>一元二次方程的解法</b></font></p> </td> </tr> <tr> <tdbgcolor="#990000"> <h2><fontcolor="#ffffff">x<sub><avvu1i8">满教批友记叶成决coration:none"><fontcolor="#ffffff">1</font></a></sub>=<inputsize="45"name="x1"type="text"><br> x<sub>2</sub>=<inputsize="45"name="x2"type="text"></font></h2> </td> </tr> <tr> </tr> </tbody> </table></form><p>MadebyCRoot</p><s学星整与criptlanguage="JavaScript"><!-- varrootparti;varrootpart;vardet;varrootparti1;varrootpa许广更广标内孩汉分苏九rti2;vara;varb;varc;varx1;varx2;vari="i";地大位族展functioncheckQuad(){vara=document.fquad.fa.value;varb=document.fquad.fb.value;varc=document.fquad.fc.value;if(a==0&&c!=0)先件案均{x1=-c/b;x2="Notaquad局叶罪刻尔庆待些raticequation,buthereisyouranswerforx";document.fquad.x1.value=因信苦如作河和盾南x1;document.fquad.x2.value=x2;}elseif(a留色哥北调液证考数植==""&&c!=该0){x1=-c/b;x2="Notaquadraticequation";document.fquad.x1.value=x1;document.fquad.x2.value=x2;}else{quad(); }}functionquad(){var送增那妒资国就背a=document.fquad.fa.value;varb=document.fquad.fb.value;varc=document.fquad.fc.value;det=Math.pow(b,2)-4*a*c;rootpart=Math.sqrt(det)/(2*a);rootparti=(Math.sqrt(-det)/(2*a))+i;if(parseFloat(rootparti)<0){rootparti1=rootparti;rootparti2=(-1*parseFloat(rootparti))+i;}else{rootparti1=(-1*parseFloat(rootparti))+i;rootparti2=rootparti;}if(rootparti1=="1i"){rootparti1=i;rootparti2="-i";}elseif(rootparti1=="-1i"){rootparti1="-i";rootparti2=i;}if(det==0){x1=x2=-b/(2*a);}elseif(det>0){x1=(-b+Math.sqrt(det))/(2*a);x2=(-b-Math.sqrt(det))/(2*a);}elseif((-b/(2*a))==0){x1=rootparti1;x2=rootparti2;}else{x1=(-b/(2*a)+"+"+rootparti1);x2=(-b/(2*a)+"+"+rootparti2);}document.fquad.x1.value=x1;document.fquad.x2.value=x2;}//willsolveforcomplexnumbers // --></script></body></html>