--- tags: DICE C --- 15-6 奇數還是偶數? === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](/@CHAWTeam/DiceC) --- 題目 -- ```! 寫一個程式,輸入一個整數, 如果是偶數,印出「(此數)是偶數」; 如果是奇數,則印出「(此數)是奇數」。 此程式可以重複執行,直到輸入的值為0 輸入範例: 78 45 0 輸出範例: 78是偶數 45是奇數 ``` 程式碼 -- ```c= #include <stdio.h> int main() { int x; scanf("%d", &x); while (x != 0) { if (x % 2 == 0) printf("%d是偶數\n", x); else printf("%d是奇數\n", x); scanf("%d", &x); } return 0; } ``` 執行 -- ### 輸入 ```! 78 45 0 ``` ### 輸出 ```! 78是偶數 45是奇數 ``` --- [查看我們在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-15-6" 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