示例#1
0
        public void get_geartless(Rational_fraction f)
        {
            int geater = 0;
            int less   = 0;

            foreach (Rational_fraction i in frac)
            {
                if (value(i) > value(f))
                {
                    geater++;
                }
                if (value(i) < value(f))
                {
                    less++;
                }
            }
            Console.WriteLine(">{0}/{1}: {2}", f.numerator, f.denominator, geater);
            Console.WriteLine("<{0}/{1}: {2}", f.numerator, f.denominator, less);
            return;
        }
示例#2
0
        public void get_minmax()
        {
            double            minf    = value(frac[0]);
            double            maxf    = value(frac[0]);
            Rational_fraction fracmax = frac[0];
            Rational_fraction fracmin = frac[0];

            foreach (Rational_fraction i in frac)
            {
                if (value(i) > maxf)
                {
                    maxf = value(i); fracmax = i;
                }
                if (value(i) < minf)
                {
                    minf = value(i); fracmin = i;
                }
            }
            Console.WriteLine("Max: {0}/{1}, Min: {2}/{3}", fracmax.numerator, fracmax.denominator,
                              fracmin.numerator, fracmin.denominator);
            return;
        }
示例#3
0
        static void Main(string[] args)
        {
            Fractions         arrF1 = new Fractions();
            Fractions         arrF2 = new Fractions();
            Rational_fraction F     = new Rational_fraction(1, 4);
            Random            rd    = new Random();

            for (int i = 0; i < 5; i++)
            {
                arrF1.add(rd.Next(1, 10), rd.Next(1, 10));
                arrF2.add(rd.Next(1, 10), rd.Next(1, 10));
            }
            arrF1.get_minmax();
            arrF1.get_geartless(F);
            Polynomial Poly1 = new Polynomial();
            Polynomial Poly2 = new Polynomial();
            Polynomial Poly3 = new Polynomial();

            Poly1.frac = arrF1.frac;
            Poly2.frac = arrF2.frac;
            Poly3      = Poly1 + Poly2;
            Poly3.show();
            return;
        }
示例#4
0
 double value(Rational_fraction f)
 {
     return(Convert.ToDouble(f.numerator) / Convert.ToDouble(f.denominator));
 }