예제 #1
0
        static void Main(string[] args)
        {
            SoPhuc a = new SoPhuc();

            a.nhap();
            a.xuat();
            SoPhuc b = new SoPhuc();

            b.nhap();
            b.xuat();
            Console.WriteLine("\n====================================================");
            SoPhuc c = a + b;

            Console.WriteLine("\nKet qua phep cong 2 so phuc vua nhap: " + c.ToString());
            SoPhuc d = a - b;

            Console.WriteLine("Ket qua phep tru 2 so phuc vua nhap: " + d.ToString());
            SoPhuc e = a * b;

            Console.WriteLine("Ket qua phep nhan 2 so phuc vua nhap: " + e.ToString());
            SoPhuc f = a / b;

            Console.WriteLine("Ket qua phep chia 2 so phuc vua nhap: " + f.ToString());
            Console.WriteLine("\n====================================================");
            Console.WriteLine("Kiem tra so phuc la so thuc hay so thuan ao!!!");
            SoPhuc g = new SoPhuc();

            g.nhap();
            g.xuat();
            if (!(bool)g)
            {
                Console.WriteLine("So phuc nay la so thuc!!!");
            }
            else
            {
                Console.WriteLine("So phuc nay la so thuan ao!!!");
            }
            Console.WriteLine("\n====================================================");
            Console.WriteLine("So sanh 2 so phuc!!!");
            SoPhuc h = new SoPhuc();

            h.nhap();
            h.xuat();
            SoPhuc k = new SoPhuc();

            k.nhap();
            k.xuat();
            Console.WriteLine("Hai so phuc bang nhau: {0}", h == k);
            Console.WriteLine("Hai so phuc khac nhau: {0}", h != k);
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            SoPhuc sp1 = new SoPhuc();
            SoPhuc sp2 = new SoPhuc();
            SoPhuc sp3 = new SoPhuc();

            Console.WriteLine("=======VUI LONG NHAP VAO CAC SO PHUC=======");
            Console.WriteLine("");
            Console.WriteLine("-So phuc thu nhat");
            Console.WriteLine("");
            sp1.nhap();
            sp1.xuat();
            Console.WriteLine("");
            Console.WriteLine("==================");
            Console.WriteLine("");
            Console.WriteLine("-So phuc thu hai");
            Console.WriteLine("");
            sp2.nhap();
            sp2.xuat();
            Console.WriteLine("==================");
            Console.WriteLine("Tong cua 2 so phuc la : ");
            sp3 = sp1 + sp2;
            sp3.xuat();
            Console.WriteLine("==================");
            Console.WriteLine("Hieu cua 2 so phuc la : ");
            sp3 = sp1 - sp2;
            sp3.xuat();
            Console.WriteLine("==================");
            Console.WriteLine("Tich cua 2 so phuc la : ");
            sp3 = sp1 * sp2;
            sp3.xuat();
            Console.WriteLine("==================");
            Console.WriteLine("Thuong cua 2 so phuc la : ");
            sp3 = sp1 / sp2;
            sp3.xuat();
            Console.ReadLine();
        }