Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- double a, b, c;
- a = double.Parse(Console.ReadLine());
- b = double.Parse(Console.ReadLine());
- c = double.Parse(Console.ReadLine());
- double D = b * b - 4 * a * c;
- double x, x1, x2;
- if (D > 0)
- {
- x2 = (-b + System.Math.Sqrt(D)) / (2 * a);
- x1 = (-b - System.Math.Sqrt(D)) / (2 * a);
- Console.WriteLine("x1={0}; x2={1}", x1, x2);
- }
- else if (D < 0)
- {
- Console.WriteLine("no real roots");
- }
- else
- {
- x = (-b + System.Math.Sqrt(D)) / (2 * a);
- Console.WriteLine("x1=x2={0}", x);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement