2017/3/9

10783 - Odd Sum

#include <iostream>
using namespace std;
int main() {
    int testCase = 0, a = 0, b = 0,count=0;
    cin>>testCase;
    while (testCase--) {
        int total = 0;
        cin >> a>>b;
        for (int i = a; i <= b; i++) {
            if (i % 2 != 0) {
                total += i;
            }
            
        }
        count++;
        cout<<"Case"<<" "<<count<<": "<<total<<"\n";
        
    }
    
    return 0;
}
UVA此題目網址http://bit.ly/2m374Lm

沒有留言:

張貼留言