Пример #1
0
        private void btnTongPS_Click(object sender, EventArgs e)
        {
            int tusoA  = int.Parse(this.tbTuSoa.Text);
            int mausoA = int.Parse(this.tbmauSoa.Text);
            int tusoB  = int.Parse(this.tbtusob.Text);
            int mausoB = int.Parse(this.tbmausob.Text);

            Phanso kq = new Phanso(tusoA, mausoA) + new Phanso(tusoB, mausoB);

            kq             = Phanso.Reduce(kq);
            this.lbKQ.Text = "Ket qua cong hai phan so:" + kq.tuso + "/" + kq.mauso;
        }
Пример #2
0
        public static Phanso Reduce(Phanso phanso)
        {
            int divisor, numerator, denomnator, reduceNumerator, reduceDenomnator;

            numerator  = phanso.tuso;
            denomnator = phanso.mauso;

            divisor = gcd(numerator, denomnator);

            if (divisor != 1)
            {
                reduceNumerator  = division(numerator, denomnator);
                reduceDenomnator = division(numerator, denomnator);
                return(new Phanso(reduceNumerator, reduceDenomnator));
            }
            else
            {
                return(phanso);
            }
        }
Пример #3
0
        public static bool operator ==(Phanso a, Phanso b)
        {
            Phanso kq = a - b;

            return(kq.tuso == 0);
        }