--- tags: DICE C --- 8-4 是否與7相關? === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[8_3 是否直角三角形?](https://hackmd.io/@CHAWTeam/DiceC-8_3) 下一篇:[8_5 是否為3的倍數-1?](https://hackmd.io/@CHAWTeam/DiceC-8_5) --- 題目 --- ```! 寫一個程式,輸入1個整數,判斷這個數是否為7的倍數,或是最末位7的數, 如果是,印出「(此數)符合標準」; 如果不是,印出「(此數)不符合標準」。 以下提供 2 種範例參考,你的輸出只會是其中一種: 輸入範例1: 17 輸出範例1: 17符合標準 輸入範例2: 55 輸出範例2: 55不符合標準 ``` 程式碼 --- ```c= #include <stdio.h> int main() { int x; scanf("%d", &x); if (x%7 == 0 || x/1%10 == 7) { printf("%d符合標準\n", x); } else { printf("%d不符合標準\n", x); } scanf("%d", &x); if (x%7 == 0 || x/1%10 == 7) { printf("%d符合標準\n", x); } else { printf("%d不符合標準\n", x); } scanf("%d", &x); if (x%7 == 0 || x/1%10 == 7) { printf("%d符合標準\n", x); } else { printf("%d不符合標準\n", x); } return 0; } ``` 輸出 --- ```! 17 17符合標準 ``` ```! 55 55不符合標準 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[8_3 是否直角三角形?](https://hackmd.io/@CHAWTeam/DiceC-8_3) 下一篇:[8_5 是否為3的倍數-1?](https://hackmd.io/@CHAWTeam/DiceC-8_5) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-8-4" 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