--- tags: DICE C --- 16-1 1到100和 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 -- ```! 計算整數1到100,公差為1的累加和。 如1+2+3+...+100的和。 輸出範例: 5050 C範例程式: #include <stdio.h> int main() { int i,sum; for(............){ sum=sum+i; } printf("%d\n",sum); return 0; } C++範例程式: #include <iostream> #include <stdio.h> int main() { int i,sum; for(i=1,sum=0;i<=100;i++){ sum=sum+i; } std::cout<<sum; return 0; } ``` 程式碼 -- ```c= #include <stdio.h> int main() { int i, sum; for (i = 1; i <= 100; i++) { sum = sum + i; } printf ("%d\n", sum); return 0; } ``` 輸出 -- ```! 5050 ``` --- [查看我們在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-1" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}