Ejemplo n.º 1
0
            static void Main(string[] args)
            {
                MyArr Point1 = new MyArr(1, 12, -4);
                MyArr Point2 = new MyArr(0, -3, 18);

                Console.WriteLine("Координаты первой точки: " +
                                  Point1.x + " " + Point1.y + " " + Point1.z);
                Console.WriteLine("Координаты второй точки: " +
                                  Point2.x + " " + Point2.y + " " + Point2.z + "\n");

                MyArr Point3 = Point1 + Point2;

                Console.WriteLine("\nPoint1 + Point2 = "
                                  + Point3.x + " " + Point3.y + " " + Point3.z);
                Point3 = Point1 - Point2;
                Console.WriteLine("Point1 - Point2 = "
                                  + Point3.x + " " + Point3.y + " " + Point3.z);
                Point3 = -Point1;
                Console.WriteLine("-Point1 = "
                                  + Point3.x + " " + Point3.y + " " + Point3.z);
                Point2++;
                Console.WriteLine("Point2++ = "
                                  + Point2.x + " " + Point2.y + " " + Point2.z);
                Point2--;
                Console.WriteLine("Point2-- = "
                                  + Point2.x + " " + Point2.y + " " + Point2.z);

                Console.ReadLine();
            }
Ejemplo n.º 2
0
            // Перегружаем унарный оператор -
            public static MyArr operator -(MyArr obj1)
            {
                MyArr arr = new MyArr();

                arr.x = -obj1.x;
                arr.y = -obj1.y;
                arr.z = -obj1.z;
                return(arr);
            }
Ejemplo n.º 3
0
            // Перегружаем бинарный оператор -
            public static MyArr operator -(MyArr obj1, MyArr obj2)
            {
                MyArr arr = new MyArr();

                arr.x = obj1.x - obj2.x;
                arr.y = obj1.y - obj2.y;
                arr.z = obj1.z - obj2.z;
                return(arr);
            }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            MyArr arr = new MyArr(10);

            for (int i = 0; i < 10; i++)
            {
                arr[i] = i;
                Console.Write(arr[i] + " ");
            }
        }
Ejemplo n.º 5
0
        public ArClass(int size)
        {
            MyArr = size != 0 ? new int[size] : new int[rnd.Next(1, 10)];

            for (int i = 0; i < MyArr.Length; i++)
            {
                MyArr[i] = rnd.Next(1, 101);
            }

            //используем LINQ
            ArrSum = MyArr.Sum();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // First array

            MyArr one = new MyArr();

            int[] array = one.GetArr();

            Console.Write("Unsorted array: ");
            foreach (var item in array)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            // Merge sorting

            MSort.MergeSort(array);

            Console.Write("Merge sorted array: ");
            foreach (var item in array)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            // Second array

            RandArr two = new RandArr();

            array = two.GetArr();

            Console.Write("Unsorted array: ");
            foreach (var item in array)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            // Quick sorting

            QSort.QuickSort(array);

            Console.Write("Quick sorted array: ");
            foreach (var item in array)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            Console.ReadKey();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine();
            MyArr array = new MyArr(3);

            array[0] = 4;
            array[1] = 134;
            array[2] = 1000;

            for (int i = 0; i < array.Size; i++)
            {
                Console.Write("{0}. {1} * {2} = {3}", i + 1, Math.Sqrt(array.GetElem(i)), Math.Sqrt(array.GetElem(i)), array[i]);
                Console.WriteLine();
            }
            Console.WriteLine("\n\n");
        }
Ejemplo n.º 8
0
            public static MyArr operator -(MyArr obj1, int n)
            {
                MyArr arr = new MyArr();

                for (int i = 0; i < 4; i++)
                {
                    if (i >= n)
                    {
                        arr.a[i] = obj1.a[i + 1];
                    }
                    else
                    {
                        arr.a[i] = obj1.a[i];
                    }
                }

                return(arr);
            }
Ejemplo n.º 9
0
            static void Main(string[] args)
            {
                Console.WriteLine("Введите вектор А");
                Console.Write("Введите x: ");
                double a_1 = double.Parse(Console.ReadLine());

                Console.Write("Введите y: ");
                double a_2 = double.Parse(Console.ReadLine());

                Console.WriteLine("Введите вектор B");
                Console.Write("Введите x: ");
                double b_1 = double.Parse(Console.ReadLine());

                Console.Write("Введите y: ");
                double b_2 = double.Parse(Console.ReadLine());

                Console.WriteLine("Введите вектор C");
                Console.Write("Введите x: ");
                double c_1 = double.Parse(Console.ReadLine());

                Console.Write("Введите y: ");
                double c_2      = double.Parse(Console.ReadLine());
                double vector_1 = vector(a_1, a_2, b_1, b_2);
                double vector_2 = vector(a_1, a_2, c_1, c_2);
                double vector_3 = vector(c_1, c_2, b_1, b_2);

                if (vector_1 > vector_2 && vector_1 == vector_3)
                {
                    Console.WriteLine("наименьший А и B");
                }
                else if (vector_2 < vector_1 && vector_2 < vector_3)
                {
                    Console.WriteLine("наименьший А и C");
                }
                else if (vector_3 < vector_2 && vector_3 < vector_1)
                {
                    Console.WriteLine("наименьший C и B");
                }
                else
                {
                    Console.WriteLine("==");
                }
                int[]  a   = new int[5];
                Random rnd = new Random();

                for (int i = 0; i < 5; i++)
                {
                    a[i] = rnd.Next(1, 10);
                }

                Console.Write("Массив A: ");

                for (int i = 0; i < 5; i++)
                {
                    Console.Write(a[i] + " ");
                }
                Console.WriteLine();
                Console.Write("s: ");
                int n = int.Parse(Console.ReadLine());

                Console.WriteLine();
                if (n > -1 && n < 5)
                {
                    MyArr Point1 = new MyArr(a);
                    MyArr Point3 = Point1 - n;
                    for (int i = 0; i < 4; i++)
                    {
                        Console.Write(Point3.a[i] + " ");
                    }
                }
            }