using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch6_2
{
    class Rational
    {
        public int x;
        public int y;
        public Rational add(Rational ra1, Rational ra2)
        {
            Rational temp = new Rational();
            temp.x = ra1.x * ra2.y + ra1.y * ra2.x;
            temp.y = ra1.y * ra2.y;
            return temp;
        }
        public void sub(Rational ra1, Rational ra2, Rational temp)
        {
            temp.x = ra1.x * ra2.y - ra1.y * ra2.x;
            temp.y = ra1.y * ra2.y;

        }
        public void mul(Rational ra1, Rational ra2, Rational temp)
        {
            temp.x = ra1.x * ra2.x;
            temp.y = ra1.y * ra2.y;

        }
        public void div(Rational ra1, Rational ra2, Rational temp)
        {
            temp.x = ra1.x * ra2.y;
            temp.y = ra1.y * ra2.x;
        }
    }
}
