Пример #1
0
        static void Main(string[] args)
        {
            MyComplex A = new MyComplex(1, 1);
            MyComplex B = new MyComplex();
            MyComplex C = new MyComplex(1);
            MyComplex D = new MyComplex();

            D.InputFromTerminal();
            C = A + D;
            Console.WriteLine($"C = {C}");
            C = A + 10.5;

            Console.WriteLine($"A = {A}, B = {B}, C = {C}, D = {D}");
            C = 10.5 + A;
            D = -C;
            C = A + B + C + D;
            C = A = B = C;

            Console.WriteLine($"A = {A}, B = {B}, C = {C}, D = {D}");

            Console.WriteLine($"Re(A) = {A["realValue"]}, Im(A) = {A["imaginaryValue"]}");
            Console.WriteLine($"Re(B) = {B["realValue"]}, Im(B) = {B["imaginaryValue"]}");
            Console.WriteLine($"Re(C) = {C["realValue"]}, Im(C) = {C["imaginaryValue"]}");
            Console.WriteLine($"Re(D) = {D["realValue"]}, Im(D) = {D["imaginaryValue"]}");
        }
Пример #2
0
        public static MyComplex operator *(MyComplex a, double b)
        {
            MyComplex res = new MyComplex();

            res.Re = a.Re * b;
            res.Im = a.Im * b;
            return(res);
        }
Пример #3
0
        public static MyComplex operator *(MyComplex a, MyComplex b)
        {
            MyComplex res = new MyComplex();

            res.Re = a.Re - b.Re;
            res.Im = a.Im - b.Im;
            return(res);
        }
Пример #4
0
        public static MyComplex operator -(MyComplex a)
        {
            MyComplex res = new MyComplex();

            res.Re = -a.Re;
            res.Im = -a.Im;
            return(res);
        }
Пример #5
0
        public static MyComplex operator -(double b, MyComplex a)
        {
            MyComplex res = new MyComplex();

            res.re = a.re - b;
            res.im = a.im;
            return(res);
        }
Пример #6
0
        public static MyComplex operator -(MyComplex a, MyComplex b)
        {
            MyComplex res = new MyComplex();

            res.re = a.re - b.re;
            res.im = a.im - b.im;
            return(res);
        }
Пример #7
0
        public static MyComplex operator -(MyComplex a)
        {
            MyComplex res = new MyComplex();

            res.re = -a.re;
            res.im = -a.im;
            return(res);
        }
Пример #8
0
        public static MyComplex operator +(MyComplex a, double b)
        {
            MyComplex res = new MyComplex();

            res.re = a.re + b;
            res.im = a.im;
            return(res);
        }