将NFA转DFA的功能实现代码补充在Form3类的button7_Click函数中,具体实现如下:

private void button7_Click(object sender, EventArgs e)//NFA->DFA { // 获取NFA NFA nfa = new NFA(); nfa.set_graph(listView1_to_graph(listView1)); nfa.set_alphabet(symbolSet); nfa.set_se(startSymbol, endSymbol);

// NFA转DFA
NFA_DFA nfa_dfa = new NFA_DFA(nfa);
DFA dfa = nfa_dfa.get_dfa();

// 将DFA显示在listView2上
listView2.Items.Clear();
foreach (var state in dfa.get_graph())
{
    foreach (var tuple in state)
    {
        string startState = (tuple.Item1 + 1).ToString();
        string inputSymbol = tuple.Item2.ToString();
        string endState = (state.IndexOf(tuple) + 1).ToString();

        ListViewItem item = new ListViewItem(startState);
        item.SubItems.Add(inputSymbol);
        item.SubItems.Add(endState);

        listView2.Items.Add(item);
    }
}
label5.Text = "初始状态集:" + dfa.get_initialState().ToString();
label7.Text = "终止状态集:";
foreach (var state in dfa.get_finalStates())
    label7.Text += " " + (state + 1).ToString();
button6.Enabled = true;
将下列所给代码中的NFA转DFA功能在函数代码using System;using SystemCollectionsGeneric;using SystemComponentModel;using SystemData;using SystemDrawing;using SystemIO;using SystemLinq;using SystemReflectionEmit;using Syst

原文地址: https://www.cveoy.top/t/topic/c2TV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录