Wednesday, June 15, 2016

SOLUTION OF URI 1071


// 1071  (Mahmud_Jamil) BRUR
//  Sum of Consecutive Odd Numbers I




 #include<stdio.h>
int main()
{
    int i,a,b,c,sum;
    while(scanf("%d%d",&a,&b)==2){
        sum=0;
        if(a>b){
            c=a;
            a=b;
            b=c;
        }
        if(a%2!=0){
        for(i=a+2;i<b;i++){
            if(i%2!=0)
                sum+=i;
            }
        }
        else{
            for(i=a+1;i<b;i++){
            if(i%2!=0)
                sum+=i;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}




0 comments:

Post a Comment