求解一元二次方程式

看板CSSE作者 (謝謝)時間19年前 (2005/04/30 13:54), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串1/1
哪錯了 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
判別式b^2-4*a*c; 不用急著求平方根, 負的會 error
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
文章代碼(AID): #12SnsnZZ (CSSE)