示例#1
0
文件: PhanSo.cs 项目: war-man/OOP2018
        //public void Xuat()
        //{
        //    Console.WriteLine("{0}/{1}",tu, mau);
        //}
        public PhanSo Cong(PhanSo a, PhanSo b)
        {
            PhanSo c = new PhanSo();

            c.tu  = a.tu * b.mau + a.mau * b.tu;
            c.mau = a.mau * b.mau;
            return(c);
        }
示例#2
0
        public PhanSo Tong()
        {
            PhanSo tong = new PhanSo(0, 1);

            for (int i = 0; i < length; i++)
            {
                //tong = tong.Cong(a[i]);
                tong = tong + a[i];
            }
            return(tong);
        }
示例#3
0
        static void Main(string[] args)
        {
            PhanSo a = new PhanSo(1, 2);
            PhanSo b = a;

            b.mau = 10;
            Console.WriteLine(a);
            //// a.Nhap();
            // a.Xuat();
            //a.NghichDao();
            // PhanSo b = new PhanSo(3,4);

            ////PhanSo c = a.Cong(a, b);

            //PhanSo c = a.Cong(b).Cong(a).Cong(b);
            //Console.WriteLine("{0}+{1}={2}", a, b, c);

            //int[] a = new int[100];
            //int length = 5;

            //PhanSo[] a = new PhanSo[100];
            //int length = 5;
            //for(int i=0; i< length; i++)
            //{
            //    a[i] = new PhanSo();
            //    a[i].Nhap();
            //}
            //for (int i = 0; i < length; i++)
            //{
            //    a[i].Xuat();
            ////}
            //PhanSo[] a = new PhanSo[] { new PhanSo(1, 2),
            //                            new PhanSo(3, 4),
            //                            new PhanSo(5),
            //                            new PhanSo()
            //};

            ////foreach (PhanSo p in a)
            ////    p.Nhap();
            //foreach (PhanSo p in a)
            //    Console.WriteLine("Phan so "+ p);


            //MangPhanSo mang = new MangPhanSo();
            //mang.Nhap();
            //Console.WriteLine(mang);
            //Console.WriteLine("Tong phan so la " + mang.Tong());
            Console.ReadKey();
        }
示例#4
0
 public void Them(PhanSo p)
 {
     a[length] = new PhanSo();
     a[length] = p;
     length++;
 }
示例#5
0
文件: PhanSo.cs 项目: war-man/OOP2018
 public PhanSo Cong(PhanSo b)
 {
     return(this.Cong(this, b));
 }