AC
10783 - Odd Sum
Moderator: Board moderators
Re: Odd sum
What is your output for the following input:
2 10
and look for threads related to your problem by using the search option on the top-right. Make your post in an existing thread - don't create a new one!
2 10
and look for threads related to your problem by using the search option on the top-right. Make your post in an existing thread - don't create a new one!
Re: Odd sum
Many many thanks to you Brother sohel
Re: 10783- Why WA??
Could somebody help me? why do i get getting WA
Code: Select all
#include <iostream>
using namespace std;
int main()
{
int test=0;
int a,b;
cin >> test;
for( int i=0; i<test ;i++)
{
cin >> a >> b;
int j=a;
int sum=0;
for(j=a;j<=b;j++)
{
if(j%2)
sum=sum+j;
}
if(i!=test-1)
cout << "Case " << i+1 << ": " << sum << endl;
else
cout << "Case " << i+1 << ": " << sum;
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10783- Why WA??
Print a newline char at the end of the last line.
Check input and AC output for thousands of problems on uDebug!