将最后getchar换成system("pause")并且include
#include
#include
#include
int main(void)
{
int a;
int b;
int c;
double x1;
double x2;
double delta;
printf("请输入一元二次函数a*x*x+b*x+c=0的三个正整系数a,b,c:\n");
scanf_s("%d%d%d", &a, &b, &c);
delta = b*b - 4 * a*c;
if (delta > 0)
{
x1 = (-b + sqrt(delta)) / (2 * a);
x2 = (-b - sqrt(delta)) / (2 * a);
printf("该一元二次方程有两解:x1=%f,x2=%f", x1, x2);
}
else
{
if (delta = 0)
{
x1 = (-b) / (2 * a);
x2 = x1;
printf("该一元二次方程有唯一相同的解:x1=x2=%f", x1);
}
else
{
printf("该一元二次方程无解:");
}
}
system("pause");
return 0;
}