Wednesday, August 23, 2017

1071 Sum of Consecutive Odd Nu...URI Problem Only Solution In C#


using System;

class URI {

    static void Main(string[] args) {
       
        int x=Convert.ToInt32(Console.ReadLine());
        int y=Convert.ToInt32(Console.ReadLine());
        int A;
        int B;
       
        if(x>y)
        {
             A=x;
             B=y;
        }
        else
        {
             A=y;
             B=x;
        }
        int sum=0;
    for(int i=B+1;i<A;i++){
        if(i%2!=0){
        sum=sum+i;
        }
    }
     Console.WriteLine(sum);
    }

}

No comments:

Post a Comment