One-dimensional two-order equation for the IF statement

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.