[MM74-易] Odd1
Time Limit: 1 seconds
Problem Description
Random odd numbers in a given range or set. A range a to b, please find between a, b and all the odd. For example, the range [1,6] of all odds is 1 + 3 + 5 = 9.
Input File Format
Each set of test data for two, including two figures, namely a and b, and a and b are two numbers input range (0 ≦ a ≦ b ≦ 100).
Output Format
Each set of test data output one, the contents of a and b between (including) the sum of all odd.
Example
Problem Description
Random odd numbers in a given range or set. A range a to b, please find between a, b and all the odd. For example, the range [1,6] of all odds is 1 + 3 + 5 = 9.
Input File Format
Each set of test data for two, including two figures, namely a and b, and a and b are two numbers input range (0 ≦ a ≦ b ≦ 100).
Output Format
Each set of test data output one, the contents of a and b between (including) the sum of all odd.
Example
Sample Input: | Sample Output: |
1 5 2 4 3 7 10 11 1 1 | 9 3 15 11 1 |
- #include <iostream>
- using namespace std;
- int main() {
- // [MM74-易] Odd1
- int a, b;
- while(cin >> a >> b)
- {
- int re = 0;
- for(int i = a;i <= b;i++)
- {
- if(i % 2 != 0)
- {
- re = re + i;
- }
- }
- cout << re << endl;
- }
- return 0;
- }
沒有留言:
張貼留言