int a, b, c, x1, x2, D;
Console.WriteLine("введите a: ");
string aInput = Console.ReadLine();
if(!int.TryParse(aInput, out a))
{
Console.WriteLine("Ввидён некоректный тип данных");
return;
}
Console.WriteLine("введите b: ");
string bInput = Console.ReadLine();
if(!int.TryParse(bInput, out b))
{
Console.WriteLine("Ввидён некоректный тип данных");
return;
}
Console.WriteLine("введите c: ");
string cInput = Console.ReadLine();
if(!int.TryParse(cInput, out c))
{
Console.WriteLine("Ввидён некоректный тип данных");
return;
}
D = (int)Math.Pow(b, 2) - 4 * a * c;
if(D==0)
{
x1 = -b / 2 * a;
Console.WriteLine("Один корень " + x1);
}
else if(D < 0)
{
Console.WriteLine("Корней нет");
}
else
{
x1 = -b + (int)Math.Sqrt(D);
x2 = -b - (int)Math.Sqrt(D);
Console.WriteLine("Первый корень " + x1);
Console.WriteLine("Второй корень корень: " + x2);
}