#include <stdio.h>
#include <math.h> int main() { int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int d = pow(b, 2) - 4 * a * c;//pow是开根号,要引用math头文件
if (d >= 0)
{
int x1;
int x2;
int x;
if (d == 0)
{
x = -b / 2*a;
printf("x = %d", x);
}
else if (d > 0)
{
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
printf("x1 = %d x2 = %d", x1, x2);
}
}
else
{
printf("无根\n");
}
return 0;
}
标签:include,int,pow,一元二次方程,printf,x2,x1 From: https://blog.51cto.com/u_16220477/7558311