Exemplo n.º 1
0
        private void TapFToListView(model.TapF tapf)
        {
            listView1.Items.Clear();
            int           i        = 0;
            StringBuilder strBuild = new StringBuilder();

            label2.Text = tapf.Lable;
            foreach (var t in tapf)
            {
                foreach (string str in t.Value)
                {
                    strBuild.Append(str);
                    strBuild.Append(", ");
                }
                if (strBuild.Length == 0)
                {
                    strBuild.Append(", ");
                }
                strBuild.Length--;
                strBuild.Length--;

                if (t.Value.Count != 0)
                {
                    listView1.Items.Add(t.Key);
                    listView1.Items[i++].SubItems.Add(strBuild.ToString());
                }

                strBuild.Clear();
            }

            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Exemplo n.º 2
0
        private void KhoiTaoTapF1()
        {
            model.TapF tapf = new model.TapF();
            tapf.Lable = "Tập F1";

            List <string> listTemp = new List <string>();
            string        temp;
            int           n = listViewTapD.Items.Count;

            for (int i = 0; i < n; i++)
            {
                temp = listViewTapD.Items[i].SubItems[0].Text;

                for (int j = 1; j <= listViewMaHoa.Items.Count; j++)
                {
                    if (listViewTapD.Items[i].SubItems[j].Text == "1")
                    {
                        list.Add(j);
                        listTemp.Add(j.ToString());
                    }
                }
                tapf.Add(temp, new List <string>(listTemp));
                listTemp.Clear();
            }
            Program.listTapF.Add(tapf);
            TapFToListView(tapf);
        }
Exemplo n.º 3
0
        private void TapC_To_TapF()
        {
            List <string> listStr    = new List <string>();
            List <string> listResult = new List <string>();
            List <string> listTemp   = new List <string>();

            string[] check;
            string   resultLast;
            string   resultNearLast;

            foreach (var t in Program.listTapL[k])
            {
                foreach (string str in t.Key)
                {
                    listStr.Add(str);
                }
            }

            listResult = Tim_TapC_Tu_TapL(listStr, k + 1);
            //foreach (string str in listResult)
            //{
            //   // Console.WriteLine("Tap C: " + str);
            //}

            if (listResult.Count == 0)
            {
                MessageBox.Show("Thuật toán kết thúc!");
                Form3 frm = new Form3(k);
                frm.ShowDialog();
            }

            model.TapF tapf = new model.TapF();
            tapf.Lable = "Tập F" + ((k + 2).ToString());

            foreach (var t in Program.listTapF[k])
            {
                foreach (string str in listResult)
                {
                    check = str.Split(' ');
                    if (check.Length >= 2)
                    {
                        resultLast     = xoaPhanTuCuoi(str);
                        resultNearLast = xoaPhanTuKeCuoi(str);
                        //Console.WriteLine("Last: Near Last: "+resultLast+": "+resultNearLast);

                        tempChar = "";
                        if (t.Value.Contains(resultLast))
                        {
                            if (t.Value.Contains(resultNearLast))
                            {
                                listTemp.Add(str);
                                listToTapL.Add(str);
                            }
                        }
                    }
                }
                //foreach (string str in listTemp )
                //{
                //    Console.WriteLine("Tap D: " + str);
                //}
                if (listTemp.Any())
                {
                    tapf.Add(t.Key, new List <string>(listTemp));
                    listTemp.Clear();
                }
            }
            Program.listTapF.Add(tapf);
            TapFToListView(tapf);
            TapF_To_TapL(listToTapL);
        }