Exemplo n.º 1
0
        public int TimDuong(int dd)// tim dg tu dd den dc.
        {
            back = new int[SoCot];
            ChuaXet.Clear();
            for (int i = 0; i < SoCot; i++)
            {
                ChuaXet.Add(true);
                back[i] = 0;
            }

            for (int i = dd; i < SoCot; i++)// socot = so dinh
            {
                if (ChuaXet[i] == true)
                {
                    ThamDinh(i);
                }
            }
            for (int i = 0; i <= dd; i++)
            {
                if (ChuaXet[i] == true)
                {
                    ThamDinh(i);
                }
            }
            return(1);
        }
Exemplo n.º 2
0
 public void TaoMaTran(int soDong, int soCot)
 {
     this.SoDong = soDong;
     this.SoCot  = soCot;
     A           = new int[SoDong, SoCot];
     ChuaXet.Clear();
     for (int i = 0; i < SoCot; i++)
     {
         bool tmp = true;
         ChuaXet.Add(tmp);
     }
     CacDinhDaXoa.Clear();
 }
Exemplo n.º 3
0
        public void DocMatTranTuFile(string name)
        {
            cacDinhDaXoa.Clear();
            // file Name co cau truc sau:

            /*
             * SoDong SoCot 40 50
             * 0 0 0 0
             * 0 0 0 0
             * 0 0 0 0,
             */
            FileStream   fs  = new FileStream(name, FileMode.Open);
            StreamReader doc = new StreamReader(fs);
            string       s;

            s = doc.ReadLine();// doc dong dau tien
            s = s.Trim();
            List <int> kq = StringToInt(s);

            SoDong = kq[0];
            SoCot  = kq[1];
            A      = new int[SoDong, SoCot];
            for (int i = 0; i < SoDong; i++)
            {
                s = doc.ReadLine();
                s = s.Trim();
                List <int> kq1 = StringToInt(s);
                for (int j = 0; j < kq1.Count; j++)
                {
                    A[i, j] = kq1[j];
                }
            }
            doc.Close();
            if (isDoiXung() == true)
            {
                coHuong = false;
            }
            else
            {
                coHuong = true;
            }
            ChuaXet.Clear();
            for (int i = 0; i < SoCot; i++)
            {
                bool tmp = true;
                ChuaXet.Add(tmp);
            }
        }
Exemplo n.º 4
0
        public void ThemDinh(int id = -1, int ts = 1)
        {
            int[,] B = new int[SoDong, SoCot];
            for (int i = 0; i < SoDong; i++)
            {
                for (int j = 0; j < SoCot; j++)
                {
                    B[i, j] = A[i, j];
                }
            }
            SoDong++;
            SoCot++;
            A = new int[SoDong, SoCot];
            for (int i = 0; i < SoDong - 1; i++)
            {
                for (int j = 0; j < SoCot - 1; j++)
                {
                    A[i, j] = B[i, j];
                }
            }
            bool tmp = true;

            ChuaXet.Add(tmp);

            if (id != -1)
            {
                if (CoHuong == false)
                {
                    A[id, SoCot - 1] = ts;
                    A[SoCot - 1, id] = ts;
                }
                else
                {
                    A[id, SoCot - 1] = ts;
                }
            }

            if (isDoiXung() == true)
            {
                coHuong = false;
            }
            else
            {
                coHuong = true;
            }
        }