Квадратное уравнение в AWK
Пример для версий
Jawk 1.02,
gawk 3.1.6,
mawk 1.3.3
{ A = $1
B = $2
C = $3
if (A == 0)
print "Not a quadratic equation"
else
{ D = B*B-4*A*C
if (D == 0)
print "x = " (-B/2/A)
else if (D > 0)
{ print "x1 = " ((-B+sqrt(D))/2/A)
print "x2 = " ((-B-sqrt(D))/2/A)
}
else
{ print "x1 = (" (-B/2/A) "," (sqrt(-D)/2/A) ")"
print "x2 = (" (-B/2/A) "," (-sqrt(-D)/2/A) ")"
}
}
}
Комментарии
]]>blog comments powered by Disqus
]]>