﻿{"id":36190,"date":"2012-05-30T22:34:58","date_gmt":"2012-05-30T14:34:58","guid":{"rendered":"http:\/\/www.lanmaowang.com\/?p=36190"},"modified":"2015-04-01T20:37:07","modified_gmt":"2015-04-01T12:37:07","slug":"delphi-to-solve-a-quadratic-equation","status":"publish","type":"post","link":"http:\/\/www.lanmaowang.com\/?p=36190","title":{"rendered":"Delphi\u6c42\u89e3\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b"},"content":{"rendered":"<pre class=\"brush:delphi;toolbar:false\">Var&nbsp;a,b,c&nbsp;:Integer;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;x1,x2&nbsp;:Real;&nbsp;&nbsp;\r\nProcedure&nbsp;Solve(a,b,c&nbsp;:Integer;Var&nbsp;Fcsumx,Fcsumy&nbsp;:Real);&nbsp;&nbsp;\r\nbegin&nbsp;&nbsp;\r\n&nbsp;&nbsp;if&nbsp;sqr(b)-4*a*c&nbsp;&gt;=&nbsp;0&nbsp;then&nbsp;&nbsp;\r\n&nbsp;&nbsp;begin&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;Fcsumx&nbsp;:=(sqrt((sqr(b)-(4*a*c)))-b)\/(2*a);&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;Fcsumy&nbsp;:=(-sqrt((sqr(b)-(4*a*c)))-b)\/(2*a);&nbsp;&nbsp;\r\n&nbsp;&nbsp;end;&nbsp;&nbsp;\r\nend;&nbsp;&nbsp;\r\n&nbsp;\r\nbegin&nbsp;&nbsp;\r\n&nbsp;&nbsp;Write(&#39;\u8f93\u5165A,B,C\u4e09\u4f4d\u7cfb\u6570\uff0c\u6211\u5c06\u7b97\u51fa\u65b9\u7a0b[AX\u7684\u5e73\u65b9+BX+C=0]&#39;#10);&nbsp;&nbsp;\r\n&nbsp;&nbsp;Readln(a,b,c);&nbsp;&nbsp;\r\n&nbsp;&nbsp;Solve(a,b,c,x1,x2);&nbsp;&nbsp;\r\n&nbsp;&nbsp;if&nbsp;sqr(b)-(4*a*c)&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;Write(&#39;\u672c\u65b9\u7a0b\u65e0\u89e3!&#39;#10)&nbsp;&nbsp;\r\n&nbsp;&nbsp;else&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;sqr(b)-(4*a*c)&nbsp;=&nbsp;0&nbsp;then&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write(&#39;\u65b9\u7a0b\u53ea\u6709\u4e00\u4e2a\u89e3!&#39;#10,&#39;x1=&#39;,x1:1:1)&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write(&#39;\u65b9\u7a0b\u6709\u4e24\u4e2a\u89e3!&#39;#10,&#39;x1=&#39;,x1:1:1,&#39;&nbsp;,&nbsp;x2=&#39;,x2:1:1);&nbsp;&nbsp;\r\n&nbsp;&nbsp;Readln;&nbsp;&nbsp;\r\nend.<\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Var&nbsp;a,b,c&nbsp;:Integer;&nbsp;&nbsp; &nbsp;&nbsp;&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":36149,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[193],"tags":[198,212,169],"_links":{"self":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36190"}],"collection":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36190"}],"version-history":[{"count":1,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36190\/revisions"}],"predecessor-version":[{"id":36191,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36190\/revisions\/36191"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/media\/36149"}],"wp:attachment":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36190"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}