--- tags: 一社一服務 --- # 語法複習--for [回目錄](https://hackmd.io/@PeiYun/CppTutorial) ```cpp= for (初值設定; 執行條件; 回合收尾) 重覆內容; ``` 例題1 輸入一整數x,計算 1加到x的和 ```cpp= #include<iostream> using namespace std; int main(){ int sum=0; for(int n=1; n<=x; n++){ sum+=n; } cout<<sum; return 0; } ```
×
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