[問題] 超新手 二次方程式解
開發平台(Platform): (Ex: VC++, Gcc, Linux, ...)
C++
額外使用到的庫(Library Used) (Ex: OpenGL, ...)
問題(Question):
單純設計一個能解 real roots 的程式
ax^2+bx+c=0
Determinant X=b^2-4ac
if (X>0) cout << The roots are...;
else if (X==0) << There's only one root x=...;
但我的程式好像抓不到 x==0 請賜教
餵入的資料(Input):
a=1 b=-6 c=9
預期的正確結果(Expected Output):
There's only one root x=3.
錯誤結果(Wrong Output):
The roots are x=3 and x=3.
程式碼(Code): (請善用置底文標色功能)
http://nopaste.info/5c2878e478.html
補充說明(Supplement):
初學者請別鞭的太兇 多謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.170.198.8
→
01/07 17:01, , 1F
01/07 17:01, 1F
推
01/07 17:20, , 2F
01/07 17:20, 2F
→
01/07 19:38, , 3F
01/07 19:38, 3F
→
01/07 19:44, , 4F
01/07 19:44, 4F
→
01/07 21:30, , 5F
01/07 21:30, 5F
推
01/07 23:10, , 6F
01/07 23:10, 6F
→
01/08 02:36, , 7F
01/08 02:36, 7F
→
01/08 02:36, , 8F
01/08 02:36, 8F
→
01/08 07:56, , 9F
01/08 07:56, 9F
→
01/08 11:10, , 10F
01/08 11:10, 10F
討論串 (同標題文章)