# Odd sum 題目連結 [UVa 10783](https://onlinejudge.org/external/107/10783.pdf) ## 中文簡述 輸出在一個區間內,所有奇數的和 ## [think] 用for 迴圈給他跑就好了 ## solution: ``` #include<iostream> using namespace std; int main() { int n,i,a,b; cin>>n; for(i=1;i<=n;i++) { cin>>a>>b; int sum=0; for(int j=a;j<=b;j++) if(j%2==1) sum+=j; cout<<"Case "<<i<<": "<<sum<<endl; } } ``` ###### tags: `UVA` 回目錄 [學習筆記](/gIBZqAbWTCis7uOPp149gA)
×
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