Пример #1
0
        static void Main(string[] args)
        {
            // show struct work
            ComplexA z1 = new ComplexA(1, 2);

            Console.WriteLine("Z1 = " + z1.SumPrint());
            ComplexA z2 = new ComplexA(5, 9);

            Console.WriteLine("Z2 = " + z2.SubPrint());

            ComplexA z3 = ComplexA.Sum(z1, z2);

            Console.WriteLine("Z3 = " + z3.SumPrint());

            ComplexA z4 = ComplexA.Sub(z1, z2);

            Console.WriteLine("Z4 = " + z4.SubPrint());

            ComplexA z5 = ComplexA.Mul(z1, z2);

            Console.WriteLine("Z5 = " + z5.MulPrint());

            // show class work
            ComplexB x1 = new ComplexB(1, 2);

            Console.WriteLine("X1 = " + x1.SumPrint());
            ComplexB x2 = new ComplexB(5, 9);

            Console.WriteLine("X2 = " + x2.SubPrint());

            ComplexB x3 = ComplexB.Sum(x1, x2);

            Console.WriteLine("X3 = " + x3.SumPrint());

            ComplexB x4 = ComplexB.Sub(x1, x2);

            Console.WriteLine("X4 = " + z4.SubPrint());

            ComplexB x5 = ComplexB.Mul(x1, x2);

            Console.WriteLine("X5 = " + z5.MulPrint());
        }
Пример #2
0
 public static ComplexB Mul(ComplexB N1, ComplexB N2)
 {
     return(new ComplexB(N1.a * N2.a, N1.b * N2.b));
 }
Пример #3
0
 public static ComplexB Sub(ComplexB N1, ComplexB N2)
 {
     return(new ComplexB(N1.a - N2.a, N1.b - N2.b));
 }
Пример #4
0
 public static ComplexB Sum(ComplexB N1, ComplexB N2)
 {
     return(new ComplexB(N1.a + N2.a, N1.b + N2.b));
 }