1、代码如下:
#include<stdio.h>
#include<math.h>
int main() {
float a = 1, b = -3, c = 2;
float temp = b * b - 4 * a * c;
temp = sqrt(temp);
float left = -b / (2 * a);
float right = temp / (2 * a);
float x1 = left + right;
float x2 = left - right;
printf("x1=%f,x2=%f", x1, x2);
return 0;
}
2、运行结果截图如下: