Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class QuadraticEquation
- {
- static void Main(string[] args)
- {
- double a, b, c, d, x, x1, x2;
- Console.Write("a= ");
- a = double.Parse(Console.ReadLine());
- Console.Write("b= ");
- b = double.Parse(Console.ReadLine());
- Console.Write("c= ");
- c = double.Parse(Console.ReadLine());
- d = b * b - (4 * a * c);
- x = -b / (2 * a);
- x1 = (-b - Math.Sqrt(d)) / (2 * a);
- x2 = (-b + Math.Sqrt(d)) / (2 * a);
- if (a == 0)
- {
- Console.WriteLine("The equation is not square!");
- }
- else if (d < 0)
- {
- Console.WriteLine("Тhe equation has no real roots! D = " + d);
- }
- else if (d == 0)
- {
- Console.WriteLine("D = 0, x = " + x);
- }
- else if (d > 0)
- {
- Console.WriteLine("D = " + d + " " + "x1 = " + x1 + " " + "x2 = " + x2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment