Квадратное уравнение в Nimrod
Пример для версий
Nimrod 0.8.8
from math import sqrt
from strutils import parseFloat
var A = parseFloat(readLine(stdin))
if A == 0.0:
echo "Not a quadratic equation."
else:
var B = parseFloat(readLine(stdin))
var C = parseFloat(readLine(stdin))
var D = B * B - 4.0 * A * C
if D == 0.0:
echo "x = ", -0.5 * B / A
elif D > 0.0:
echo "x1 = ", -0.5 * (B - sqrt(D)) / A
echo "x2 = ", -0.5 * (B + sqrt(D)) / A
else:
echo "x1 = (", -0.5 * B / A, ", ", 0.5 * sqrt(-D) / A, ")"
echo "x2 = (", -0.5 * B / A, ", ", -0.5 * sqrt(-D) / A, ")"
Комментарии
]]>blog comments powered by Disqus
]]>