http://uva.onlinejudge.org/external/107/10783.html
#include<stdio.h>
int main()
{
int n,sum,a,b,l,p;
scanf("%d",&n);
{
for(p=1;p<=n;p++)
{
scanf("%d%d",&a,&b);
sum=0;
for(l=a;l<=b;l++)
{
if(l%2!=0)
sum=sum+l;
}
printf("Case %d: %d\n",p,sum);
}
}
return 0;
}
#include<stdio.h>
int main()
{
int n,sum,a,b,l,p;
scanf("%d",&n);
{
for(p=1;p<=n;p++)
{
scanf("%d%d",&a,&b);
sum=0;
for(l=a;l<=b;l++)
{
if(l%2!=0)
sum=sum+l;
}
printf("Case %d: %d\n",p,sum);
}
}
return 0;
}
No comments:
Post a Comment