--- tags: DICE C --- 21-3 算平方根 === > [name=CHAWTeam] 目錄:[DICE C語言程式破解](/@CHAWTeam/DiceC) 題目 --- ```! 使用C語言的math.h或者C++cmath的sqrt( )函式來計算x的平方根,直到輸入的x=0.0為止。 請輸出到小數第一位。 輸入範例: 9.0 25.0 16.0 0.0 輸出範例: 3.0 5.0 4.0 ``` 程式碼 --- ```c= #include <stdio.h> #include <math.h> int main() { float x; scanf("%f", &x); while (x != 0) { printf("%.1f\n", sqrt(x)); scanf("%f", &x); } return 0; } ``` 執行 --- ### 輸入 ```! 9.0 25.0 16.0 0.0 ``` ### 輸出 ```! 3.0 5.0 4.0 ``` --- [查看我們在HackMD上的所有筆記](/@CHAWTeam) 目錄:[DICE C語言程式破解](/@CHAWTeam/DiceC) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-21-3" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}
×
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