--- tags: DICE C --- 17-4 5的倍數不加 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 -- ```! 輸入1個整數N, 從1加到N, 但如果相加的數字為5的倍數就不加, 輸出總和。 舉例,N=6, 則1+2+3+4+6=16。 輸入範例: 33 輸出範例: 456 ``` 程式碼 -- ```c= #include <stdio.h> int main() { int n, sum = 0; scanf("%d", &n); for (int i = 1; n >= i; i++) { if (i % 5 != 0) sum += i; } printf("%d", sum); return 0; } ``` 執行 -- ```! 33 456 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-17-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