(C syntax) real number root of a quadratic equation, real number of a quadratic equation

Source: Internet
Author: User

(C syntax) real number root of a quadratic equation, real number of a quadratic equation

Knowledge point:

Mathematical function header file # include <math. h>

Square functions, sqrt ()

Note the difference between equal sign = and value =

 

Content: returns the real number root of an unary quadratic equation (the quadratic system is not 0) ax2 + bx + c = 0 (a =0 ).

Input description:

Three coefficients in one row (separated by spaces)

Output description:

 

First output (-B + sqrt ()/2/a root, one row per row, if it is equal to the real root, output one (both retain two decimal places)

. If there is No real root output, No answer!

 

Input example:

1 1 2

Output example:

No answer!

 

 1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5  float a,b,c,d,x1,x2; 6  scanf("%f %f %f",&a,&b,&c); 7  d=b*b-4*a*c; 8  if (d>=0) 9  {10   x1=(-b+sqrt(d))/(2*a);11   x2=(-b-sqrt(d))/(2*a);12   if(x1==x2)13   {14    printf("%.2f\n",x1);15   }16   else17   {18    printf("%.2f\n%.2f\n",x1,x2);19   }20  }21  else 22  {23   printf("No answer!\n");24  }25  return 0;26 }

 


If there are two equal real numbers for the quadratic equation a (1 + x ^ 2) + 2bx = c (^ 2) of x, judge the shape of a triangle with the edge length a, B, and c

Simplification, (a + c) x ^ 2 + 2bx + a-c = 0
△= 0, (2b) ^ 2-4 (a + c) (a-c) = 0. a ^ 2 = B ^ 2 + c ^ 2
Right Triangle.

A mathematical problem proves that a B c is the three sides of △abc, and a quadratic equation (a-c) x square-2 (a-B) x + a + c-2b = 0 has two real numbers

[The question should be "there are two equal real numbers "]

(A-c) x ^ 2-2 (a-B) x + a + c-2b = 0 has two [equal] real number roots
Discriminant [-2 (a-B)] ^ 2-4 * (a-c) * (a + c-2b) = 0
(A-B) ^ 2-(a-c) * (a + c-2b) = 0
B ^ 2-2bc + c ^ 2 = 0
(B-c) ^ 2 = 0
B = c, isosceles triangle

Related Article

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.