Exemplo n.º 1
0
            public static Dathuc operator -(Dathuc dt1, Dathuc dt2)
            {
                Dathuc dt_tong = new Dathuc();

                for (int i = 0; i < dt1.Sopt; i++)
                {
                    dt_tong.ThemSohang(dt1.DT[i].Hs, dt1.DT[i].Mu);
                }

                for (int i = 0; i < dt2.Sopt; i++)
                {
                    dt_tong.ThemSohang(dt2.DT[i].Hs, dt2.DT[i].Mu);
                }

                dt_tong.SapGiamDanTheoSoMu();

                for (int i = 0; i < dt_tong.Sopt - 1; i++)
                {
                    if (dt_tong.DT[i].Mu == dt_tong.DT[i + 1].Mu)
                    {
                        dt_tong.DT[i].Hs -= dt_tong.DT[i + 1].Hs;

                        for (int j = i + 1; j < dt_tong.Sopt - 1; j++)
                        {
                            dt_tong.DT[j] = dt_tong.DT[j + 1];
                        }

                        dt_tong.Sopt--;
                        i--;
                    }
                }

                return(dt_tong);
            }
Exemplo n.º 2
0
            public static Dathuc operator +(Dathuc dt1, Dathuc dt2)
            {
                Dathuc dt_tong = new Dathuc();

                for (int i = 0; i < dt1.Sopt; i++)
                {
                    dt_tong.ThemSohang(dt1.DT[i].Hs, dt1.DT[i].Mu);
                }

                for (int i = 0; i < dt2.Sopt; i++)
                {
                    dt_tong.ThemSohang(dt2.DT[i].Hs, dt2.DT[i].Mu);
                }

                dt_tong.SapGiamDanTheoSoMu();
                dt_tong.RutGonDaThuc();

                return(dt_tong);
            }