Квадратное уравнение в Boo
Пример для версий
boo 0.8.2
A = int.Parse(prompt("A = "))
if A==0 :
print "Not a quadratic equation."
return
B = int.Parse(prompt("B = "))
C = int.Parse(prompt("C = "))
D = B*B-4*A*C
if D==0 :
x = -0.5*B/A
print "x = ${x}"
return
if D>0 :
x1 = 0.5*(-B-System.Math.Sqrt(D))/A
x2 = 0.5*(-B+System.Math.Sqrt(D))/A
print "x1 = ${x1}"
print "x2 = ${x2}"
else :
r = -0.5*B/A
i = 0.5*System.Math.Sqrt(-D)/System.Math.Abs(A)
print "x1 = (${r},${i})"
print "x2 = (${r},-${i})"
Комментарии
]]>blog comments powered by Disqus
]]>