解一元二次方程

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include<math.h>
 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 }
posted @ 2019-12-19 13:06  MegaByte  阅读(154)  评论(0)    收藏  举报