Ejemplo n.º 1
0
        public void SumElemArray()
        {
            var taskRun = new TwoArray();

            taskRun.countLine        = 5;
            taskRun.countRow         = 5;
            taskRun.leftBoderToRand  = -100;
            taskRun.rightBoderToRand = 100;
            taskRun.fraction         = 1;
            taskRun.InitMultyArray();
            taskRun.PrintMultyArray();
            Console.WriteLine($"\nThe sum elements between min and max = {taskRun.SumBetweenMinMax():F0}");
        }
Ejemplo n.º 2
0
        public void WorkWithArray()
        {
            var taskRun = new TwoArray();

            taskRun.SizeArray = 5;
            taskRun.countLine = 3;
            taskRun.countRow  = 4;

            taskRun.InitSingleArray();
            taskRun.InitMultyArray();

            Console.WriteLine("\nA:");
            taskRun.Print();

            Console.WriteLine("\nB:");
            taskRun.PrintMultyArray();

            double maxCommonElement;

            if (taskRun.IsCommonMaxElement(out maxCommonElement))
            {
                Console.WriteLine($"\nThe maximum common element is {maxCommonElement:F2}");
            }

            double minCommonElement;

            if (taskRun.IsCommonMaxElement(out minCommonElement))
            {
                Console.WriteLine($"\nThe maximum common element is {minCommonElement:F2}");
            }

            var sum = taskRun.SumElemSingleArray() + taskRun.SumElemMultyArray();

            Console.WriteLine($"\nThe sum all elements of the array A and B is {sum:F2}");

            var multipl = taskRun.MultElemSingleArray() * taskRun.MultElemMultyArray();

            Console.WriteLine($"\nThe product all elements of the array A and B is {multipl:F2}");

            var sumEven = taskRun.SumEvenElemSingleArray();

            Console.WriteLine($"\nThe sum even elements of the array A is {sumEven:F2}");

            var sumOddRow = taskRun.SumOddRowMultyArray();

            Console.WriteLine($"\nThe sum odd rows of the array B is {sumOddRow:F2}\n");
        }
Ejemplo n.º 3
0
        public void IntersectArray()
        {
            var taskInput    = new Lab1.InputIntData();
            var createArray1 = new TwoArray();

            Console.WriteLine("Enter size of the array M:");
            createArray1.SizeArray = taskInput.InputData();

            var createArray2 = new TwoArray();

            Console.WriteLine("Enter size of the array N:");
            createArray2.SizeArray = taskInput.InputData();

            createArray1.InitSingleArray();
            createArray2.InitSingleArray();

            double[] array = createArray1.CreateIntersecArray(createArray1.GetSingleArray(), createArray2.GetSingleArray());
            Console.WriteLine("\nIntersect array:");
            createArray1.Print(array);
            Console.WriteLine();
        }