1、#include #include #include using namespace std; #define max 100 struct edge string first;/边的初始结点string change;/边的条件string last;/边的终点; int N;/NFA 的边数vector value; /求状态集合 I 的 for(i=0;ibi.first; if(bi.first=“#“)break; else cinbi.changebi.last; N=i; coutFirstLast; coutChange; Tx=closure(First,b); Tx=sor
2、t(Tx); value.push_back(0); i=0; while(valuei=0 for(j=0;jChange.length();j+) ss=“; ss=move(Ti,Changej,b); length=value.size(); for(h=0;hlength;h+) if(Th=sort(closure(ss,b)break; if(h=length) T+x=sort(closure(ss,b); value.push_back(0); i+; edge *DFA=new edgemax; for(i=0;i=x;i+)/构造 DFA 的各边 for(j=0;jCha
3、nge.length();j+) DFAd.first=Ti; DFAd.change=Changej; ss=“; ss=sort(closure(move(Ti,Changej,b),b); for(m=0;m=x;m+) if(ss=Tm)DFAd+.last=Tm; cout“此 NFA 构造的 DFA 的各边信息如下: “endl“起点条件终点“endl; for(i=0;id;i+) for(m=0;m=x;m+) if(DFAi.first=Tm)coutm“ “DFAi.change; for(m=0;m=x;m+) if(DFAi.last=Tm)cout“ “mendl; cout“该 DFA 的初态为:“; for(m=0;m=x;m+) for(j=0;jTm.length();j+) ss=Tm; if(ssj=First0)coutmendl; cout“该 DFA 的终态为:“; for(m=0;m=x;m+) for(j=0;jTm.length();j+) ss=Tm; if(ssj=Last0)coutm“ “; coutendl; system(“pause“);