Exemple #1
0
        static Diem LayDiemNgauNhien(int[,] arr)
        {
            var rd   = new Random();
            var list = new List <Diem>();

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (arr[i, j] == 1)
                    {
                        var diem = new Diem(i, j);
                        list.Add(diem);
                    }
                }
            }
            if (list.Count == 0)
            {
                return(null);
            }
            return(list[rd.Next(0, list.Count)]);
        }
Exemple #2
0
        public List <List <Diem> > CacDuongDiTrongMang()
        {
            var ret = new List <List <Diem> >();

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (Arr[i, j] == 1)
                    {
                        var diem = new Diem(i, j);
                        var arr1 = Arr.Clone() as int[, ];
                        arr            = arr1;
                        tapDiemDaDuyet = new List <Diem>();
                        TimTheoDuongThang(diem);
                        if (tapDiemDaDuyet.Count > 1)
                        {
                            ret.Add(tapDiemDaDuyet);
                        }
                    }
                }
            }
            return(ret);
        }