--- tags: DICE C --- 17-10 象限 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](/@CHAWTeam/DiceC) --- 題目 -- ```! 請撰寫一程式, 輸入x、y座標,請判斷該點,位於哪一象限或是座標軸上。 程式重複輸入,直到x、y座標皆等於0才停止。 輸入範例: 5.2 6.1 -2.5 -3.5 2.5 0.0 0.0 0.0 輸出範例: 第一象限 第三象限 x軸 ``` 程式碼 -- ```c= #include <stdio.h> int main() { float x, y; scanf("%f %f", &x, &y); while (x != 0 || y != 0) { if (x == 0) printf("y軸\n"); if (y == 0) printf("x軸\n"); if (x > 0 && y > 0) printf("第一象限\n"); if (x < 0 && y > 0) printf("第二象限\n"); if (x < 0 && y < 0) printf("第三象限\n"); if (x > 0 && y < 0) printf("第四象限\n"); scanf("%f %f", &x, &y); } return 0; } ``` 執行 -- ### 輸入 ```! 5.2 6.1 -2.5 -3.5 2.5 0.0 0.0 0.0 ``` ### 輸出 ```! 第一象限 第三象限 x軸 ``` --- [查看我們在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-17-10" 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