コード例 #1
0
        public void MedianFinder_Solutions()
        {
            var obj = new MedianFinder();

            obj.AddNum(1);
            obj.AddNum(2);
            Assert.AreEqual(1.5, obj.FindMedian());

            obj.AddNum(3);
            Assert.AreEqual(2, obj.FindMedian());
        }
コード例 #2
0
        public void MedianFinder_Solutions_2()
        {
            var obj = new MedianFinder();

            obj.AddNum(6);
            Assert.AreEqual(6.0, obj.FindMedian());

            obj.AddNum(10);
            Assert.AreEqual(8.0, obj.FindMedian());

            obj.AddNum(2);
            Assert.AreEqual(6.0, obj.FindMedian());

            obj.AddNum(6);
            Assert.AreEqual(6.0, obj.FindMedian());

            obj.AddNum(5);
            Assert.AreEqual(6.0, obj.FindMedian());

            obj.AddNum(0);
            Assert.AreEqual(5.5, obj.FindMedian());

            obj.AddNum(6);
            Assert.AreEqual(6.0, obj.FindMedian());

            obj.AddNum(3);
            Assert.AreEqual(5.5, obj.FindMedian());

            obj.AddNum(1);
            Assert.AreEqual(5.0, obj.FindMedian());

            obj.AddNum(0);
            Assert.AreEqual(4.0, obj.FindMedian());

            obj.AddNum(0);
            Assert.AreEqual(3.0, obj.FindMedian());
        }