예제 #1
0
파일: Program.cs 프로젝트: r1kozin/PP2_Labs
        static void Main(string[] args)
        {
            string text = Console.ReadLine();

            string[] s  = text.Split(' ');
            string[] n1 = s[0].Split('/');
            string[] n2 = s[1].Split('/');
            int      a  = int.Parse(n1[0]);
            int      b  = int.Parse(n1[1]);
            int      c  = int.Parse(n2[0]);
            int      d  = int.Parse(n2[1]);

            complex c1   = new complex(a, b);
            complex c2   = new complex(c, d);
            complex sum  = c1 + c2;
            complex dif  = c1 - c2;
            complex prod = c1 * c2;
            complex div  = c1 / c2;

            Console.WriteLine(sum);
            Console.WriteLine(dif);
            Console.WriteLine(prod);
            Console.WriteLine(div);

            Console.ReadKey();
        }
예제 #2
0
        public static void Main(string[] args)
        {
            complex a = new complex(3, 5);
            complex b = new complex(2, 5);
            complex n = a + b;

            Console.WriteLine(a + "+" + b + "=" + n);
            Console.ReadKey();
        }
예제 #3
0
        public static complex operator +(complex c1, complex c2)
        {
            complex n = new complex();

            n.y = c2.y * c1.y;
            n.x = c1.x * n.y / c1.y + c2.x * n.y / c2.y;

            n.Cancel();


            return(n);
        }