★◎请教一元2次方程的根◎★
/********************************************************** Highlight software by yzfy(雨中飞燕) http:// *
*********************************************************/
#include<stdio.h>
double f1(double a,double b,double c)
{
double a,b,c;
scanf("%d%d%d",a,b,c);
printf("x1=-%d+sqrt(%d-%d)\n",b,b*b,4*a*c);
printf("x2=-%d-sqrt(%d-%d)\n",b,b*b,4*a*c);
}
double f2(double a,double b,double c)
{
double a,b,c,s;
scanf("%d%d%d",a,b,c);
printf("x=-%d-sqrt(%d-%d)\n",b,b*b,4*a*c);
}
double f3(double a,double b,double c)
{
double a,b,c,s1,s2;
scanf("%d%d%d",a,b,c);
printf("x1=-%d+sqrt(%d-%d)*i\n",b,b*b,4*a*c);
printf("x2=-%d-sqrt(%d-%d)*i\n",b,b*b,4*a*c);
}
main()
{
double a,b,c,d;
scanf("%d%d%d",a,b,c);
d=b*b-4*a*c;
if(d>0)
f1(a,b,c);
else if(d==0)
f2(a,b,c);
else(d<0)
f3(a,b,c);
}
[程序错误很多,由于我不懂函数,自己检查不出错。大家帮帮忙。
[[it] 本帖最后由 bianchengfeng 于 2008-5-12 10:18 编辑 [/it]]