TOPIC

Solution (C++)

Gabriel818 asked 4 years ago

include

using namespace std;

int main(){

int x, y, s, i;

s = 0;

cin >> x >> y;

for(i = y + 1; i < x; i++){
    if(i % 2 != 0){
        s = s + i ;
    }
}
cout << s << endl;

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Miracle replied 3 years ago

    O limite inferior do seu laço for será o menor dentre x e y. E o limite superior será o maior valor dentre x e y. Logo vc precisa descobrir quem é o menor e o maior número digitado