예제 #1
0
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("Numele meu este Szakacsi Ferenc-Adam");
         Console.WriteLine("Acest program lucreaza cu numere complexe");
         double   a  = double.Parse(Console.ReadLine());
         double   b  = double.Parse(Console.ReadLine());
         double   c  = double.Parse(Console.ReadLine());
         double   d  = double.Parse(Console.ReadLine());
         int      x  = int.Parse(Console.ReadLine());
         Complexe c1 = new Complexe(a, b);
         Complexe c2 = new Complexe(c, d);
         Console.WriteLine(c1);
         Console.WriteLine(c2);
         Complexe suma   = c1.Sum(c2);
         Complexe scad   = c1.Scad(c2);
         Complexe multip = c1.Mult(c2);
         Complexe putere = c1.Put(x);
         Console.WriteLine($"Suma este:{suma}");
         Console.WriteLine($"Scaderea este:{scad}");
         Console.WriteLine($"Inmultirea este:{multip}");
         Console.WriteLine($"Ridicarea la putere este:{putere}");
         c1.Trig();
         Console.ReadKey();
     }
     catch (Exception e)
     {
         Console.WriteLine($" {e.Message}");
     }
 }
예제 #2
0
        public static Complexe operator ^(Complexe x, int p)
        {
            Complexe rez = new Complexe(1);

            if (p == 0)
            {
                return(new Complexe(1));
            }
            if (p == 1)
            {
                return(x);
            }
            for (int i = 0; i < p; i++)
            {
                rez = rez * x;
            }
            return(rez);
        }
예제 #3
0
        public virtual Complexe Put(int put)
        {
            Complexe x   = new Complexe(re, im);
            Complexe rez = new Complexe(1);

            if (put == 0)
            {
                return(new Complexe(1));
            }
            if (put == 1)
            {
                return(x);
            }
            for (int i = 0; i < put; i++)
            {
                rez = rez * x;
            }
            return(rez);
        }
예제 #4
0
        public Complexe Mult(Complexe c2)
        {
            Complexe rezultat = new Complexe((re * c2.re) - (im * c2.im), (im * c2.re) + (re * c2.im));

            return(rezultat);
        }
예제 #5
0
        public Complexe Scad(Complexe c2)
        {
            Complexe rezultat = new Complexe(re - c2.re, im - c2.im);

            return(rezultat);
        }
예제 #6
0
        public Complexe Sum(Complexe c2)
        {
            Complexe rezultat = new Complexe(c2.re + re, c2.im + im);

            return(rezultat);
        }