编写C语言程序:求出方程Y=3X^2+6X+9 的最小值

编写出C语言程序
2024-11-16 09:30:45
推荐回答(2个)
回答1:

#include
#include
void main()
{
int x,a,b,c;
float Y;
clrscr();
printf("Please input 3 numbers:\n");
scanf("%d%d%d",&a,&b,&c);
printf("The equation is:Y=%d*x^2+%d*x+%d",a,b,c);
if(a!=0&&a>0)
{
x=-b/(2*a);
Y=(4*a*c-b*b)/(4*a);
printf("\nWhen x is %d the equation can make a min\n",x);
printf("The min of the equation is:%f",Y);
}
else if(a!=0&&a<0)
{
x=-b/(2*a);
Y=(4*a*c-b*b)/(4*a);
printf("\nWhen x is %d the equation can make a max\n",x);
printf("The max of the equation is:%f",Y);
}
getch();
}

回答2:

#include"stdio.h"
void main()
{
int a,b,c;
printf("请输入整数系数\n");
scanf("%d %d %d",&a,&b,&c);
printf("%f",(4.0*a*c-b*b)/(4*a));
}