解一元二次方程

 1 #include 
 2 #include 
 3 #include
 4 
 5 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 6 
 7 int main(int argc, char *argv[]) {
 8 
 9     int a,b,c;
10     a=6,b=13,c=2;
11     double x1,x2;
12     if(b*b-4*a*c>=0)
13     {
14         x1=((-b-sqrt(b*b-4*a*c))/(2*a));
15         x2=((-b+sqrt(b*b-4*a*c))/(2*a));
16         printf("x1=%lf\t x2=%lf",x1,x2);
17      }
18      else
19      {
20          printf("此方程无解\n");
21      } 
22     return 0;
23 }

你可能感兴趣的:(解一元二次方程)