Пример #1
0
        public static complex operator +(complex c1, complex c2)
        {
            complex c3 = new complex(0, 0);

            c3.a = c1.a * c2.b + c2.a * c1.b;
            c3.b = c1.b * c2.b;
            return(c3);
        }
Пример #2
0
        static void Main(string[] args)
        {
            string  s   = Console.ReadLine();
            string  c   = s.Split(' ')[0];
            string  d   = s.Split(' ')[1];
            int     a_  = int.Parse(c.Split('/')[0]);
            int     b_  = int.Parse(c.Split('/')[1]);
            int     c_  = int.Parse(d.Split('/')[0]);
            int     d_  = int.Parse(d.Split('/')[1]);
            complex a   = new complex(a_, b_);
            complex b   = new complex(c_, d_);
            complex sum = a + b;

            Console.WriteLine(sum);
            Console.ReadKey();
        }
Пример #3
0
            static void Main(string[] args)
            {
                int     a  = 9;
                int     b  = 3;
                int     c  = 4;
                int     d  = 2;
                complex c1 = new complex(a, b);
                complex c2 = new complex(c, d);
                complex c3 = c1 + c2;

                for (int i = 1; i <= c3.a; i++)
                {
                    if (c3.a % i == 0 && c3.b % i == 0)
                    {
                        c3.a = c3.a / i;
                        c3.b = c3.b / i;
                    }
                }
                Console.WriteLine(c3);
                Console.ReadKey();
            }