示例#1
0
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("Numele meu este Szakacsi Ferenc-Adam");
         Console.WriteLine("Acest program lucreaza cu numere rationale");
         int       a  = int.Parse(Console.ReadLine());
         int       b  = int.Parse(Console.ReadLine());
         int       c  = int.Parse(Console.ReadLine());
         int       d  = int.Parse(Console.ReadLine());
         int       x  = int.Parse(Console.ReadLine());
         Rationale r1 = new Rationale(a, b);
         Rationale r2 = new Rationale(c, d);
         Console.WriteLine(r1 + r2);
         Console.WriteLine(r1 - r2);
         Console.WriteLine(r1 * r2);
         Console.WriteLine(r1 / r2);
         Console.WriteLine(r1 ^ x);
         Console.ReadKey();
     }
     catch (Exception e)
     {
         Console.WriteLine($" {e.Message}");
     }
 }
示例#2
0
        public static Rationale operator ^(Rationale x, int n)
        {
            Rationale rezultat = x;

            for (int i = 0; i < n - 1; i++)
            {
                rezultat *= x;
            }
            return(rezultat);
        }