Пример #1
0
        public void Test()
        {
            int[] array = new int[] { 7, 8, 3, 4, 2, };
            SegmentTree tree = new SegmentTree(array);
            tree.PlusSegment(0, 4, 1);
            tree.AssignSegment(0, 4, 0);
            tree.Assign(1, 3);
            tree.Plus(2, -1);

            Assert.AreEqual(2, tree.Sum(0, 4));
        }
Пример #2
0
        static void Main(string[] args)
        {
            int[] array = new int[] { 7, 8, 3, 4, 2, 11, 9, 6 };
            SegmentTree tree = new SegmentTree(array);

            Console.WriteLine();
            try
            {
                tree.Assign(-1, 5);
            }
            catch (Exception e) { Console.WriteLine(e.Message); }

                Console.ReadKey();
        }