--- tags: DICE C --- 8_2 是否能構成三角形? === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[8_1 奇數還是偶數?](https://hackmd.io/@CHAWTeam/DiceC-8_1) 下一篇:[8_3 是否直角三角形?](https://hackmd.io/@CHAWTeam/DiceC-8_3) --- 題目 --- ```! 寫一個程式,輸入3個整數邊長,判斷其能否構成三角形, 如果是請印出「(3個邊長)可以構成三角形」; 否則印出,「(3個邊長)不可以構成三角形」。 以下提供 2 種範例參考,你的輸出只會是其中一種: 輸入範例1: 3 3 3 輸出範例1: 3 3 3可以構成三角形 輸入範例2: 2 4 6 輸出範例2: 2 4 6不可以構成三角形 ``` 程式碼 --- ```cpp= #include <stdio.h> int main() { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (a + b > c && b + c > a && c + a > b) printf("%d %d %d可以構成三角形", a, b, c); else printf("%d %d %d不可以構成三角形", a, b, c); return 0; } ``` 輸出 --- ```! 3 3 3 3 3 3可以構成三角形 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[8_1 奇數還是偶數?](https://hackmd.io/@CHAWTeam/DiceC-8_1) 下一篇:[8_3 是否直角三角形?](https://hackmd.io/@CHAWTeam/DiceC-8_3) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-8-2" 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