Пример #1
0
        static void Main(string[] args)
        {
            //1
            double eps    = 0;
            double dx     = 9;
            int    x0     = 2;
            Newton newton = new Newton(eps);

            Console.WriteLine("Результат: " + newton.Exec(x0, dx));

            //Task2
            int[,] array = { { 26, 22, 14 }, { 23, 5, 13 }, { 44, 8, 11 } };
            Console.WriteLine("Input array");
            BubbleSortTask.Display(array);

            SumSort ss     = new SumSort(true);
            Sorter  sorter = new Sorter(ss);

            Console.WriteLine("\r\nIn order of decreasing sums of elements of rows of the matrix");
            sorter.ChangeSortType(new SumSort(false));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);

            Console.WriteLine("\r\nIn order of increasing sums of elements of rows of the matrix");
            sorter.ChangeSortType(new SumSort(true));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);

            Console.WriteLine("\r\nIn order of decreasing max element of rows of the matrix");
            sorter.ChangeSortType(new MaxSort(false));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);

            Console.WriteLine("\r\nIn order of increasing max element of rows of the matrix");
            sorter.ChangeSortType(new MaxSort(true));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);

            Console.WriteLine("\r\nIn order of decreasing min element of rows of the matrix");
            sorter.ChangeSortType(new MinSort(false));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);

            Console.WriteLine("\r\nIn order of increasing min element of rows of the matrix");
            sorter.ChangeSortType(new MinSort(true));
            array = sorter.Sort(array);
            BubbleSortTask.Display(array);
            Console.ReadKey();
        }
Пример #2
0
        public void NewtonExec_Normal_Test()
        {
            // arrange
            double eps      = 0;
            double dx       = 9.0;
            int    x0       = 2;
            Newton newton   = new Newton(eps);
            double expected = 3;

            // act
            double result = newton.Exec(x0, dx);

            // assert
            Assert.AreEqual(expected, result, "Correctly");
        }
Пример #3
0
        public void NewtonExec_NegativeValues_Test()
        {
            // arrange
            double eps    = -0.0001;
            double dx     = -8;
            int    x0     = 2;
            Newton newton = new Newton(eps);
            ArgumentOutOfRangeException expectedException = null;

            // act
            try
            {
                double result = newton.Exec(x0, dx);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                expectedException = ex;
            }


            // assert
            Assert.IsNotNull(expectedException);
        }