public void TestMethod1() { int[] array = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; SegmentTree tree = new SegmentTree(array); tree.PlusSegment(0, 7, 5); int sum = tree.Sum(0, 7); Assert.AreEqual(40, sum); }
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)); }
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(); }