資源簡介
程序用VS2015,C++來實現的,運用了很多C++的知識,實現了正則式—》NFA—》DFA—》DFA最小化。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace??std;
#define?NULL?0
#define?LStack?linkedStack
//?鏈式棧類的前視定義
template?
class?linkedStack;
//?定義鏈式棧結點類
template?
class?StackNode
{
friend?class?linkedStack;
private:
T?data;
StackNode?*next;
StackNode(T?item?=?0?StackNode?*p?=?NULL)
{
data?=?item;
next?=?p;
}
};
//?定義鏈式棧類
template?
class?linkedStack
{
private:
StackNode?*top;
public:
linkedStack();
~linkedStack();
bool?IsEmpty(void)?const;
int?Length(void)?const;
void?Push(const?T?&item);
T?Pop(void);
T?GetTop(void);
void?Clear(void);
};
//?構造函數
template?
linkedStack::linkedStack()
{
top?=?NULL;
}
//?析構函數
template?
linkedStack::~linkedStack()
{
Clear();
}
//?判斷棧是否為空
template?
bool?linkedStack::IsEmpty(void)?const
{
return?(!top);
}
//?獲取隊列的長度
template?
int?linkedStack::Length(void)?const
{
StackNode?*temp?=?new?StackNode();
temp?=?top;
int?length?=?0;
while?(temp)
{
temp?=?temp->next;
length++;
}
return?length;
}
//?壓入數據(入棧)
template?
void?linkedStack::Push(const?T?&item)
{
top?=?new?StackNode(item?top);
}
//?抽出數據(出棧)
template?
T?linkedStack::Pop(void)
{
if?(!IsEmpty())
{
StackNode?*temp?=?top;
top?=?top->next;
T?value?=?temp->data;
delete?temp;
return?value;
}
else
{
cout?<“Stack?Already?Empty!“?< _getch();
exit(1);
}
}
//?獲取棧頭數據
template?
T?linkedStack::GetTop(void)
{
if?(!IsEmpty())
{
return?top->data;
}
else
{
cout?<“Stack?Already?Empty!“?< _getch();
exit(1);
}
}
//?設置棧為空棧
template?
void?linkedStack::Clear(void)
{
StackNode?*temp?=?new?StackNode();
while?(top)
{
temp?=?top;
top?=?top->next;
delete?temp;
}
}
//?定義鄰接表的邊表類
class?Edge
{
public:
int?number;
int?position;
char?weight;
Edge?*link;
Edge();
Edge(int?num?int?pos?char?ch);
};
Edge::Edge()
{
number?=?-1;
position?=?-1;
link?=?NULL;
}
Edge::Edge(int?num?int?pos?char?ch)
{
number?=?num;
position?=?pos;
weight?=?ch;
link?=?NULL;
}
//?定義鄰接表的頂點類
class?Vertex
{
public:
int?number;
Vertex?*next;
Edge?*out;
Vertex();
Vertex(int?num);
};
Vertex::Vertex()
{
number?=?-1;
next?=?NULL;
out?=?NULL;
}
Vertex::Vertex(int?num)
{
number?=?num;
next?=?NULL;
out?=?NULL;
}
//?用鄰接表定義的圖類
class?AdjacentTable
{
private:
Vertex?*startVertex;
int?numOfVertices;
int?numOfEdges;
public:
AdjacentTable();
~AdjacentTable();
int?GetValueByPos(int?pos)?const;
int?GetPosByValue(int?value)?const;
char?GetWeightByPos(int?v1?int?v2)?const;
char?GetWeightByValue(int?value1?int?value2)?const;
void?SetValue(int?value?int?pos);
void?InsertVertex(i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\.vs\
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\.vs\DFA-NFA\
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\.vs\DFA-NFA\v14\
?????文件???????22528??2015-10-08?12:34??DFA-NFA\.vs\DFA-NFA\v14\.suo
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\Debug\
?????文件???????92160??2015-10-08?12:31??DFA-NFA\Debug\DFA-NFA.exe
?????文件??????447848??2015-10-08?12:31??DFA-NFA\Debug\DFA-NFA.ilk
?????文件?????1019904??2015-10-08?12:31??DFA-NFA\Debug\DFA-NFA.pdb
?????文件????11141120??2015-10-08?12:34??DFA-NFA\DFA-NFA.sdf
?????文件????????1303??2015-10-01?12:14??DFA-NFA\DFA-NFA.sln
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\DFA-NFA\
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\DFA-NFA\Debug\
?????文件????????1383??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.log
?????文件??????156240??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.obj
?????目錄???????????0??2015-10-08?12:35??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\
?????文件?????????668??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\CL.command.1.tlog
?????文件???????10602??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\CL.read.1.tlog
?????文件?????????376??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\CL.write.1.tlog
?????文件?????????169??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\DFA-NFA.lastbuildstate
?????文件????????1050??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\li
?????文件????????2758??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\li
?????文件?????????348??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\DFA-NFA.tlog\li
?????文件??????330752??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\vc140.idb
?????文件??????380928??2015-10-08?12:31??DFA-NFA\DFA-NFA\Debug\vc140.pdb
?????文件???????22650??2015-10-08?12:36??DFA-NFA\DFA-NFA\DFA-NFA.cpp
?????文件????????7474??2015-10-08?11:58??DFA-NFA\DFA-NFA\DFA-NFA.vcxproj
?????文件?????????948??2015-10-01?12:26??DFA-NFA\DFA-NFA\DFA-NFA.vcxproj.filters
- 上一篇:A星尋路算法c++語言實現
- 下一篇:完整的c++指紋識別系統源碼
評論
共有 條評論