Exemplo n.º 1
0
        } // ненужен

        public static Drobi operator ^(Drobi one, int n)
        {
            Drobi result = new Drobi(1, 1);

            if (n > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    result.x = result.x * one.x;
                    result.y = result.y * one.y;
                }
            }
            else if (n < 0)
            {
                for (int i = 0; i < Math.Abs(n); i++)
                {
                    result.x = result.x * one.x;
                    result.y = result.y * one.y;
                }
                int temp = result.x;
                result.x = result.y;
                result.y = temp;
            }

            return(result);
        }
Exemplo n.º 2
0
        public void Power(int n)
        {
            Drobi result = new Drobi(1, 1);

            if (n > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    result.x = result.x * x;
                    result.y = result.y * y;
                }
            }
            else if (n < 0)
            {
                for (int i = 0; i < Math.Abs(n); i++)
                {
                    result.x = result.x * x;
                    result.y = result.y * y;
                }
                int temp = result.x;
                result.x = result.y;
                result.y = temp;
            }
            result.Sokr();
            result.Show();
        } // ненужен
Exemplo n.º 3
0
        public static Drobi operator /(int n, Drobi two)
        {
            Drobi result = new Drobi();

            result.x = two.y * n;
            result.y = two.x * 1;
            result.Sokr();
            return(result);
        }
Exemplo n.º 4
0
        public static Drobi operator /(Drobi one, int n)
        {
            Drobi result = new Drobi();

            result.x = one.x * 1;
            result.y = one.y * n;
            result.Sokr();
            return(result);
        }
Exemplo n.º 5
0
        } // ненужен

        public static Drobi operator /(Drobi one, Drobi two)
        {
            Drobi result = new Drobi();

            result.x = one.x * two.y;
            result.y = one.y * two.x;
            result.Sokr();
            return(result);
        }
Exemplo n.º 6
0
        public static Drobi operator *(int n, Drobi two)
        {
            Drobi result = new Drobi();

            result.x = n * two.x;
            result.y = 1 * two.y;
            result.Sokr();
            return(result);
        }
Exemplo n.º 7
0
        public void Dele(Drobi drobi)
        {
            if (drobi.y == 0)
            {
                drobi.y = 1;
            }
            Drobi result = new Drobi(drobi.y, drobi.x);

            Mult(result);
        } // ненужен
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Drobi a = new Drobi("6/9");
            Drobi b = new Drobi(6, 3);

            Console.WriteLine(a < b);
            Console.WriteLine((double)a);
            //int q = 1;
            //q += 3;
            Console.ReadLine();
        }
Exemplo n.º 9
0
        public void Mult(Drobi drobi) // ненужен
        {
            Drobi result = new Drobi();

            if (drobi.y == 0)
            {
                drobi.y = 1;
            }
            result.x = x * drobi.x;
            result.y = y * drobi.y;
            result.Sokr();
            result.Show();
        }
Exemplo n.º 10
0
        public static bool operator ==(Drobi one, Drobi two)
        {
            Drobi oneCopy = new Drobi(one.x, one.y);
            Drobi twoCopy = new Drobi(two.x, two.y);

            oneCopy.Sokr();
            twoCopy.Sokr();
            if (oneCopy.x == twoCopy.x && oneCopy.y == twoCopy.y)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 11
0
        } // ненужен

        public static Drobi operator -(Drobi one, Drobi two)
        {
            Drobi result = new Drobi();

            if (one.y == two.y)
            {
                result.x = one.x - two.x;
                result.y = one.y;
            }
            else
            {
                result.x = one.x * two.y - two.x * one.y;
                result.y = one.y * two.y;
            }
            return(result);
        }
Exemplo n.º 12
0
        public void Minus(Drobi drobi)
        {
            Drobi result = new Drobi();

            if (y == drobi.y)
            {
                result.x = x - drobi.x;
                result.y = y;
            }
            else
            {
                result.x = x * drobi.y - drobi.x * y;
                result.y = y * drobi.y;
            }
            result.Sokr();
            result.Show();
        } // ненужен