Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CuadraticEquision
- {
- static void Main()
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- int c = int.Parse(Console.ReadLine());
- double d = b*b - (4 * a * c);
- double x1, x2;
- if ((d > 0 ) && (a != 0))
- {
- x1 = ((-b) + Math.Sqrt(d)) / 2*a;
- x2 =((-b) - Math.Sqrt(d)) / 2 *a;
- Console.WriteLine("the equision has two roots: {0} and {1}.", x1, x2);
- }
- else if((a == 0) || (d < 0))
- {
- Console.WriteLine("This is not a quadratic equision or the equision has no real roots!");
- }
- else if (d == 0)
- {
- Console.WriteLine("This equision has one root: x = {0}.",(-b)/(2*a));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement