Example #1
0
        static void Main()
        {
            int[] T = { 6, -10, 5, -1, 4, 8, -3, 9, 11, -40, 6, 18 };

            HS O = HighestSection(T);

            Console.Write("Numbers:");
            foreach (int x in O.GetT())
            {
                Console.Write(" " + x);
            }
            Console.Write("\nSum: " + O.GetS());

            // --- OUTPUT --- //
            //Numbers: 5 -1 4 8 -3 9 11
            //Sum: 33
        }
Example #2
0
        static HS HighestSection(int[] I)
        {
            HS O = new HS();
            HS M = new HS();

            foreach (int x in I)
            {
                if (O.GetS() < 0)
                {
                    O = new HS();
                }
                O.Insert(x);
                if (O.GetS() > M.GetS())
                {
                    M = O.Clone();
                }
            }
            ;

            return(M);
        }