回 帖 发 新 帖 刷新版面

主题:[原创]求助用QBasic

本人是初学者 寻找帮助 10万火急 
 谁能用QBasic 帮我解1个方程啊?
   ax2+bx+c=0
 2是X的2次方  求2个根~~
  我先谢谢各位了。。。偶菜鸟。。

回复列表 (共2个回复)

沙发

input "a,b,c=";a,b,c
if a=0 then
 if b=0 then
   if c=0 then
     print "方程有无数解"
  else
     print "方程无解"
   end if
  else
  print "x=";-b/(2*a)
  end if
else
d=b^2-4*a*c
 if d<0 then 
  print "方程无解"
  else
   p=-b/(2*a)
   q=sqr(d)/(2*a)
   if d=0 then 
    print "x=";p
   else
    print "x1=";p-q,"x2=";p+q
   end if
 end if 
end if
end

板凳

第 1 楼   

input "a,b,c=";a,b,c
if a=0 then
 if b=0 then
   if c=0 then
     print "方程有无数解"
  else
     print "方程无解"
   end if
  else
  print "x=";-b/(2*a)
  end if
 
end     
好象到这里就ok拉

我来回复

您尚未登录,请登录后再回复。点此登录或注册