用c++实现,NFA到DFA的转换,请教高手。讲一下思想。

来源:百度知道 编辑:UC知道 时间:2024/09/21 13:35:09
思想最重要了。

#include "stdafx.h"
#include <vector>
#include <string>
#include <queue>
#include <iostream>

using namespace std;

struct Transform
{
friend class FA;
char state1;
char letter;
char state2;
bool operator!=(char ch);
friend istream& operator>>(istream& in,Transform& t);
};
struct ChangeTable
{
string state;
int flag;
vector<string> changestate;
};
bool Transform::operator!=(char ch)
{
return state1!=ch||letter!=ch||state2!=ch;
}
namespace std
{
istream& operator>>(istream& in,Transform& t)
{
return in>>t.state1>>t.letter>>t.state2;
}
}
class FA
{
private:
vector<char> state; //状态集
vector<char> table; //输入字母表
vector<Transform> fun; //状态变迁函数
char q0; //初态
vec