Exemplo n.º 1
0
 public static int Main()
 {
     try
     {
         Fraction f = new Fraction(3, 4);
         Console.WriteLine("Задана дробь {0}", f);
         int a = 10;
         Fraction f1 = f * a;
         Console.WriteLine("{0} * {1} = {2}", f, a, f1);
         Fraction f2 = a*f;
         Console.WriteLine("{0} * {1} = {2}", a, f, f2);
         double d = 1.5;
         Fraction f3 = f + d;
         Console.WriteLine("{0} + {1} = {2}", f, d, f3);
         return 1;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 0;
     }
 }
Exemplo n.º 2
0
 public static Fraction operator +(Fraction f1, double numerator)
 {
     int i1 = (int)numerator;
     int denomirator = 1;
     while (i1 - numerator < 0)
     {
         denomirator *= 10;
         numerator *= 10;
         i1 = (int)numerator;
     }
     Fraction temp = new Fraction(i1, denomirator);
     return f1 + temp;
 }
Exemplo n.º 3
0
 public static Fraction operator *(Fraction f1, int i)
 {
     Fraction temp = new Fraction(i, 1);
     return temp*f1;
 }