plzzzz tell me why i getting runtime error...
#include<stdio.h>
int main()
{ int i,j,sum,a,b,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a);
scanf("%d",&b);
sum=0;
for(j=a;j<=b;j++)
{
if(j%2!=0)
sum=sum+j;
}
printf("Case %d: %d\n",i,sum);
}
}
Search found 2 matches
- Thu Mar 29, 2012 7:12 am
- Forum: Volume 107 (10700-10799)
- Topic: 10783 - Odd Sum
- Replies: 34
- Views: 22183
- Thu Mar 29, 2012 5:35 am
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 77378
Re: 10055 - Hashmat the Brave Warrior
Why i getting time limit exceeded??? i use integer,,long,,long long all data types....
#include<stdio.h>
int main()
{
long long a,b,c;
for(;;)
{
scanf("%lld %lld",&a,&b);
if(a<b)
{ c=b-a;
printf("%lld\n",c);
}
if(a>b)
{ c=a-b;
printf("%lld\n",a-b);
}
}
return 0;
}
#include<stdio.h>
int main()
{
long long a,b,c;
for(;;)
{
scanf("%lld %lld",&a,&b);
if(a<b)
{ c=b-a;
printf("%lld\n",c);
}
if(a>b)
{ c=a-b;
printf("%lld\n",a-b);
}
}
return 0;
}