Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Example
- {
- class Program
- {
- static void Main()
- {
- double a = double.Parse(Console.ReadLine());
- double b = double.Parse(Console.ReadLine());
- double c = double.Parse(Console.ReadLine());
- if (a > 0)
- {
- double x1 = 0;
- double x2 = 0;
- double discriminant = b * b - 4 * (a * c);
- if (discriminant > 0)
- {
- x1 = ((-b) - Math.Sqrt(discriminant)) / 2 * a;
- x2 = ((-b) + Math.Sqrt(discriminant)) / 2 * a;
- Console.WriteLine($"X1 = {x1}");
- Console.WriteLine($"X2 = {x2}");
- }
- else if (discriminant == 0)
- {
- x1 = (-b) / 2 * a;
- Console.WriteLine($"X1 = {x1}");
- }
- else
- {
- Console.WriteLine("No real roots!");
- }
- }
- else
- {
- Console.WriteLine("Queficent a should be bigger than zero.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment