C程序,请帮我看看有什么不对

来源:百度知道 编辑:UC知道 时间:2024/05/08 21:25:04
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void main()
{
float a,b,c,max,min;
scanf("%f,%f,%f",&a,&b,&c);
if(a>0)
{
min=(4*a*c-b*b)/4a;
printf("minimun is %f\n",min);
}
else
{
max=(4*a*c-b*b)/4a;
printf("maximum is %f\n",max);
system("pause");
}

}
你们说的好像都不对,我想可能是因为声明的变量没有充分利用造成的。

system("pause"); 因为有这条语句,所以你还应该添加头文件#include <windows.h> 否则编译软件会提示错误,有这个是为了在windows 环境下直接运行程序的 再者system("pause"); 应放在if else 结构的外面
#include <math.h> 可以去掉,貌似你没有用到数学公式啊
还应添加判断方程解的情况 b*b-4*a*c是否大于0
你程序中的4a应写成4*a 呵呵 这是粗心的错误
祝你好运

a=0怎么办?