Ideas: 1, first understand what is called a two-time equation, when a is not equal to 0, this equation is a two-time equation
2, according to the formula Derta=b*b-4*a*c to determine the root of the situation
①derta>0, the equation has two unequal real roots
②derta=0, the equation has two equal real roots
When ③derta<0, the equation has no real roots
3, first of all to determine whether this equation is a two-time equation, if it is, in judging the root of the situation
Console.WriteLine ("find the equation a*x*x+bx+c=0"); Console.WriteLine ("Please enter a="); DoubleA=convert.todouble (Console.ReadLine ()); Console.WriteLine ("Please enter b="); Doubleb =convert.todouble (Console.ReadLine ()); Console.WriteLine ("Please enter c="); Doublec =convert.todouble (Console.ReadLine ()); Doublezz= b*b-4*a*c;//defines the square -4ac of a variable b if(A! =0)//first determine whether the two-second equation is established{Console.WriteLine ("the equation is a unary two-time equation"); if(ZZ >0) {Console.WriteLine ("the equation has two different real roots"); DoubleX1 = (-B + math.sqrt (ZZ))/(2* a);//math.sqrt () is the root class Doublex2 = (-b-math.sqrt (ZZ))/(2*a); Console.WriteLine (x1); Console.WriteLine (x2); } Else if(ZZ = =0) {Console.WriteLine ("the equation has two identical"); DoubleX1 = (-B + math.sqrt (ZZ))/(2*a); Console.WriteLine (x1); } Else{Console.WriteLine ("There is no solution to the two-dimensional equation"); } } Else{Console.WriteLine ("the equation is not a unary two-time equation"); }
One-dimensional two-order equation for the IF statement