Exemplo n.º 1
0
        public ComplexSruct Plus(ComplexSruct inpCompl)
        {
            ComplexSruct outCompl;

            outCompl.im = im + inpCompl.im;
            outCompl.re = re + inpCompl.re;
            return(outCompl);
        }
Exemplo n.º 2
0
        public ComplexSruct Minus(ComplexSruct inpCompl)
        {
            ComplexSruct outCompl;

            outCompl.im = im - inpCompl.im;
            outCompl.re = re - inpCompl.re;
            return(outCompl);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            #region Task1.1
            Console.WriteLine("Work of structures...");
            ComplexSruct complex1;
            complex1.im = 5;
            complex1.re = 10;
            Console.WriteLine($"First number: {complex1}");

            ComplexSruct complex2;
            complex2.im = -7;
            complex2.re = -5;
            Console.WriteLine($"Second number: {complex2}");

            ComplexSruct result = complex1.Plus(complex2);
            Console.WriteLine($"Result of summ: {result}");

            result = complex1.Minus(complex2);
            Console.WriteLine($"Result of minus: {result}");

            Console.ReadKey();
            Console.Clear();
            #endregion


            #region Task1.2
            Console.WriteLine("Work of classes...");
            ComplexClass complexClassDefault = new ComplexClass();
            Console.WriteLine($"Craeted default ComplexClass: {complexClassDefault}");

            ComplexClass complexClass1 = new ComplexClass(8, -5);
            Console.WriteLine($"First number: {complexClass1}");

            ComplexClass complexClass2 = new ComplexClass(-3, 4);
            Console.WriteLine($"First number: {complexClass2}");

            Console.WriteLine($"Result of summ: {complexClass1 + complexClass2}");
            Console.WriteLine($"Result of minus: {complexClass1 - complexClass2}");
            Console.WriteLine($"Result of multiplication: {complexClass1 * complexClass2}");

            Console.ReadKey();
            #endregion
        }