求解一元二次方程式
哪錯了
compile不出來
各位大大指教我吧
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
float judge(float,float,float);//判斷式函數
int main(void)
{
float a,b,c;//declare a int variable
printf("input the three varibles a,b,c");
scanf("%d,%d,%d",&a,&b,&c);
judge(a,b,c);
float d;//jugement variable
d=judge(a,b,c);//indicate the of jugement equation to d variable
if(d>0)
{
float r1,r2;
r1=(-b+d)/(2*a),r2=(-b-d)/(2*a);
printf("the answe is %f,%f,\n",r1,r2);
}
else if(d=0)
{
float rr;//root reapted!
rr=-b/(2*a);
printf("the answer is double roots %f",rr);
}
else
{
float r,c1,c2;//r represents a real part,c1 and c2 is complex part
r=-b/2*a;
c1=d;
c2=-d;
printf("the answe is %f+i%f and %f+i%f,r,c1,r,c2");
}
return 0;
}
float judge(float a,float b,float c)
{
float d,e;
d=b*b-4*a
e=sqrt(d);
return e;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.114.150.35
推
211.76.58.8 05/01, , 1F
211.76.58.8 05/01, 1F
推
140.113.141.98 05/02, , 2F
140.113.141.98 05/02, 2F
推
140.112.30.50 05/03, , 3F
140.112.30.50 05/03, 3F
CSSE 近期熱門文章
PTT數位生活區 即時熱門文章