예제 #1
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();
        } // ненужен
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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();
        }
예제 #7
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);
        }
예제 #8
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();
        } // ненужен