--- tags: DICE C --- 5-3 梯形面積 === > [name=CHAWTeam] [time=Feb 16, 2022] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[5-2 餘數](https://hackmd.io/@CHAWTeam/DiceC-5-2) 下一篇:[5-4 溫度換算](https://hackmd.io/@CHAWTeam/DiceC-5-4) --- 題目 --- ```! 寫一個程式, 輸入上底、下底與高,求此梯形的面積。(提示:輸出到一位小數) 輸入範例: 8 13 13 輸出範例: 梯形面積=136.5平方公分 ``` ### 提示 ![](https://i.imgur.com/mwO4XmZ.png) 程式碼 --- ```c= #include <stdio.h> int main() { float a, b, c; scanf("%f %f %f", &a, &b, &c); printf("梯形面積=%.1f平方公分", (a+b)*c/2); return 0; } ``` :::warning 被除數或除數至少要有一個**被定義為浮點數**,電腦計算出來的結果才會是小數! ::: 輸出 --- ```! 8 13 13 梯形面積=136.0平方公分 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[5-2 餘數](https://hackmd.io/@CHAWTeam/DiceC-5-2) 下一篇:[5-4 溫度換算](https://hackmd.io/@CHAWTeam/DiceC-5-4) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-5-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