###### tags: `實習額外加分題` 第一次實習課額外練習題 === ## Video {%youtube 4B1n7A0PqgQ %} --- ## Description 國中時有學過一元二次方程式求解時會使用求根公式,如下(相信大家記得) **公式:** $\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}$ 舉例來說: $x^2+2x+1$ 帶入此公式會得到 $x = -1$,因為 a 係數是 1, b 係數是 2,c 係數是 1 所以本周的題目即是利用 a、b、c 結合求根公式求出 x 為多少 **注意,程式沒有辦法在一行就表達正負這件事,所以正的解要用一行,負的解要用一行來分開運算哦** 提示: <span style="color:red">根號請引用 cmath 函示庫並使用其 sqrt 函數,[不懂請看第一周實習課錄影]()</span> --- ## Input 請輸入三個整數分別代表 a、b、c ## Output 經過求根公式運算後得到的兩個解 --- ## Sample input 1 1 2 1 ## Sample output 1 -1 -1 --- ## Sample input 2 1 5 4 ## Sample output 2 -1 -4 ---
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up