2032 奇數求和

CRt0729發表於2024-06-28
#include<bits/stdc++.h>
#define f(i,s,e) for(int i = s; i <= e; i++)
#define ll long long
using namespace std;
const int N = 1e3+10,inf = 0x3f3f3f3f;

int main()
{
    int m,n,sum = 0;
    cin >> m >> n;
    for(int i = m; i <= n; i++)
    {
        if(i % 2 == 1) //i為奇數 
        {
            sum += i; //累加i 
        }
    }
    cout << sum;
    return 0;
}

相關文章