Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Код моей программы - 2
import "dart:math";
void main() {
quadraticEquation(11, -120, -11); // Должен вывести x1=11, x2=-0.09
quadraticEquation(1, 6, 9); // Должен вывести: x=3 (правильный ответ: x=-3)
quadraticEquation(1, 1, 1); // Должен вывести: нет корней
}
void quadraticEquation(a, b, c)
{
var d = b*b - 4*a*c;
if(d >= 0)
{
var x1 = (-b + sqrt(d))/(2*a);
var x2 = (-b - sqrt(d))/(2*a);
if(x1!=x2)
print("x1=$x1 x2=$x2");
else
print("x=$x1");
}
else
print("Нет корней");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.