Пример #1
0
        public void Change(int index)
        {
            Console.WriteLine("Хотите ввести дробь(1-да/0-нет)");
            int d = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("На какое значение поменять введите большую часть");
            int h = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("На какое значение поменять введите меньшую часть");
            int s = Convert.ToInt32(Console.ReadLine());


            {
                if (index < Arr.Length)
                {
                    Changed("Элемент под номером " + (index + 1) + " заменен на элемент со значениями " + h + " " + s);
                    if (d == 1)
                    {
                        Arr[index] = new Fractional(h, s);
                    }
                    else
                    {
                        Arr[index] = new LongLong(h, s);
                    }
                }

                else
                {
                    throw new MyIndexOutOfRangeException("Нет элемента с таким индексом");
                }
            }
        }
Пример #2
0
        public static Fractional operator *(Fractional A, Fractional B)
        {
            Fractional Result = new Fractional();

            Result.small = A.small * B.small;
            Result.hight = (A.hight * B.hight);
            Result.ReduceFraction();

            return(Result);
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.Title = "Лабораторна робота 2 ";
            LongLong Test  = new LongLong(-44, 34223);
            LongLong Test2 = new LongLong(0, 4);

            Console.WriteLine(Test.toString());
            Console.WriteLine(Test2.toString());

            Console.WriteLine((Test * Test2).toString());

            Fractional A = new Fractional(-3, 8);
            Fractional B = new Fractional(-2, 5);
            Fractional C = new Fractional(-3, 5);

            Console.WriteLine(C.toString());


            Series Testing = new Series(Test);

            Console.WriteLine(Testing.toString());
            Testing.Add(Test2);
            Testing.Add(B);
            Testing.Add(C);
            Console.WriteLine(Testing.toString());
            Console.WriteLine("Поменяем 1 элемент");
            Testing.Change(1);
            Console.WriteLine(Testing.toString());
            Testing.Remove(Test);
            Console.WriteLine(Testing.toString());
            Console.WriteLine("Найдем индекс " + B.toString());
            Console.WriteLine(Testing.GetId(B));

            Console.WriteLine("Добавим к массиву сумму,разницу,результат деления и умножения чисел " + A.toString() + " " + B.toString());
            Testing.Add(A + B);
            Testing.Add(A - B);
            Testing.Add(A / B);
            Testing.Add(A * B);

            LongLong A2 = new  LongLong(2, 644569924);
            LongLong B2 = new LongLong(0, 84399477);

            Console.WriteLine("Добавим к массиву сумму,разницу,результат деления и умножения чисел " + A2.toString() + " " + B2.toString());
            // Testing.Add(A2 + B2);
            // Testing.Add(A2 - B2);


            Testing.Add(A2 + B2);
            Testing.Add(A2 - B2);
            Testing.Add(A2 / B2);
            Testing.Add(A2 * B2);


            Console.ReadKey();
        }
Пример #4
0
 public bool EqualstoPair(Fractional A)
 {
     if (A.small == small && A.hight == hight)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #5
0
        public static Fractional operator /(Fractional A, Fractional B)
        {
            bool isPlusA = A.hight > 0 ? true : false;
            bool isPlusB = B.hight > 0 ? true : false;

            A.hight = Math.Abs(A.hight);
            B.hight = Math.Abs(B.hight);

            Fractional Result = new Fractional();


            Result.hight = (A.hight * B.small);
            Result.small = A.small * B.hight;

            if (isPlusA != isPlusB)
            {
                Result.hight = -Result.hight;
            }

            Result.ReduceFraction();

            return(Result);
        }
Пример #6
0
 public bool EqualstoPair(Fractional A)
 {
     return(false);
 }