--- tags: DICE C --- 16-5 X到Y之和 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 -- ```! 輸入二整數X、Y,且X<Y, 計算整數X到Y,公差為1的累加和。 如X+(X+1)+...+Y的和。 舉例,若X=3,Y=5, 則3+4+5=12。 輸入範例: 1 99 輸出範例: 4950 ``` 程式碼 -- ```c= #include <stdio.h> int main() { int x, y, sum = 0; scanf("%d %d", &x, &y); for (; y >= x; x++) sum += x; printf("%d", sum); return 0; } ``` 執行 -- ```! 1 99 4950 ``` --- [查看我們在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-16-5" 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