Header Ads

The Stick Game (Code Express Wipro) in c sharp

 

The Stick Game (Code Express Wipro)

matt haymound is hanging  out with his school friend  Raymond. While roaming around they come across a large pile of sticks, of different sizes, Looking at the large pil. Matt is stuck with an idea and decide to challenge his friend at a new kind of game............................

input1: 4

input2: {1,2,3,9}

output: 1

using System;

class HelloWorld {

    public int stickcode(int input1, int[] input2)

    {

        int sum=0,count=0;

        for(int i=0;i<input1;i++)

        {

            for(int j=i+1;j<input1;j++)

            {

                sum=input2[i]+input2[j];

                for(int k=0;k<input1;k++)

                {

                    if(sum==input2[k])

                    {

                        count++;

                    }

                }

            }

        }

        return count;

    }

  static void Main() {

      HelloWorld s=new HelloWorld();

      int input1=3;

      int[] input2={1,2,2};

    Console.WriteLine(s.stickcode(input1,input2));

  }

}



if you need more help then comment below or drop a mail.


Powered by Blogger.