freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

測繪軟件實習(xí)報告(已修改)

2025-01-31 00:24 本頁面
 

【正文】 中國礦業(yè)大學(xué)測繪軟件設(shè)計與實現(xiàn)實驗報告學(xué)  號:     姓  名:     班  級:  指導(dǎo)教師:  王永波  實驗一 二叉樹的構(gòu)建及其遍歷算法的實現(xiàn)實驗?zāi)康模和瓿啥鏄涞臉?gòu)建以及二叉樹的遍歷等,加深對樹以及二叉樹的遍歷相關(guān)知識的理解。實驗內(nèi)容:。、中序、后序遍歷。主要代碼:template class Tclass C_LJH_BinTree { public: C_LJH_BinTree()。//構(gòu)造函數(shù),根據(jù)輸入前序序列由鍵盤輸入 ~C_LJH_BinTree()。//析構(gòu)函數(shù) void PreOrder()。//前序遍歷 void InOrder()。//中序遍歷 void PostOrder()。//后序遍歷 private: T data。 C_LJH_BinTreeT *lchild,*rchild。 bool NO_Die。}。 template class T C_LJH_BinTreeT::C_LJH_BinTree() { NO_Die = false。 lchild = NULL。 rchild = NULL。 char ch。 cinch。 if (ch == 39。39。) { NO_Die = true。//若為,代表空節(jié)點 } else { thisdata = ch。//保存輸入的節(jié)點 //左子樹 C_LJH_BinTree *newChild0 = new C_LJH_BinTreeT()。 if (newChild0NO_Die) delete newChild0。 else thislchild= newChild0。 //右子樹 C_LJH_BinTree *newChild1 = new C_LJH_BinTreeT()。//直接創(chuàng)建子節(jié)點, if (newChild1NO_Die) delete newChild1。 else thisrchild= newChild1。 } } //析構(gòu)函數(shù) template class T C_LJH_BinTreeT::~C_LJH_BinTree() { if (lchild) delete lchild。 //刪除父節(jié)點之前,先刪除子節(jié)點 if (rchild) delete rchild。 } //前序遍歷 template class T void C_LJH_BinTreeT::PreOrder() { coutthisdata\t。//先輸出父節(jié)點,然后子節(jié)點按照父節(jié)點做 if (lchild!=NULL) thislchildPreOrder()。 if (rchild!=NULL) thisrchildPreOrder()。 } //中序遍歷 template class T void C_LJH_BinTreeT::InOrder() { if (lchild) lchildInOrder()。 coutthisdata\t。 if (rchild) rchildInOrder()。 } //后序遍歷 template class T void C_LJH_BinTreeT::PostOrder() { if (lchild) lchildPostOrder()。 if (rchild) rchildPostOrder()。 coutthisdata\t。 } int main() { cout請輸入二叉樹的前序遍歷:endl。 cout(以作為分支結(jié)尾,例如:A B C )endl。 C_LJH_BinTreechar m_tree。 coutendl。 cout前序遍歷為:endl。 ()。 coutendl。 cout中序遍歷為:endl。 ()。 coutendl。 cout后序遍歷為:endl。 ()。 coutendl。 return 0。 }實驗結(jié)果:實驗體會:通過本次試驗,理解了二叉樹類的構(gòu)建、二叉樹的建立及其遍歷。作為第一次實驗,內(nèi)容上實現(xiàn)實驗所要求的目沒有多大的難處,但其從數(shù)據(jù)結(jié)構(gòu)出發(fā),讓我回憶起很多以前學(xué)過的知識,對我來說,收獲不少。實驗二 圖的創(chuàng)建、遍歷及其MST的構(gòu)建實驗?zāi)康模和瓿蓤D的創(chuàng)建、遍歷及最小數(shù)的構(gòu)建,加深對圖的認識以及對相關(guān)課本知識的認識。實驗內(nèi)容: 。 。 。 。主要代碼:struct primnode{public: char begvex。//開始結(jié)點 char endvex。//結(jié)束結(jié)點 int lowcost。//中間權(quán)值}。class LJH_Graphmtx//圖的鄰接矩陣定義{ public: LJH_Graphmtx(int sz=DefaultVertices)。//構(gòu)造函數(shù) ~LJH_Graphmtx()//析構(gòu)函數(shù) {delete []VerticesList。delete []Edge。} bool GraphEmpty()//判斷圖是否為空 { if(numEdges==0)return true。 else return false。 } bool GraphFull()//判斷圖是否為滿 {if(numVertices==maxVertices||numEdges==maxVertices*(maxVertices1)/2) return true。 else return false。 }int NumberOfVertices()//返回當(dāng)前頂點數(shù) { return numVertices。 } int NumberOfEdges()//返回當(dāng)前邊數(shù) { return numEdges。 } char getValue(int i)//取頂點i的值,i不合理返回0 { return i=0amp。amp。i=numVertices ? VerticesList[i] : NULL。 } int getWeight(int v1,int v2)//取邊(v1,v2)上的權(quán)值 { return v1!=1amp。amp。v2!=1 ? Edge[v1][v2] : 0。 } int getFirstNeighbor(int v)。//取頂點v的第一個鄰接頂點 int getNextNeighbor(int v,int w)。//取v的鄰接頂點w的下一鄰接頂點 bool insertVertex(char vertex)。//插入頂點vertex bool insertEdge(int v1,int v2,int weight)。//插入邊(v1,v2),權(quán)為weight bool removeVertex(int v)。//刪去頂點v和所有與它相關(guān)聯(lián)的邊 bool removeEdge(int v1,int v2)。//在圖中刪去邊(v1,v2) int getVertexPos(char vertex)//給出頂點vertex的位置,如果該頂點不在圖內(nèi)則返回1 { for(int i=0。inumVertices。i++) if(VerticesList[i]==vertex) return i。 return 1。 } int mini()。//求圖中所有邊的最小權(quán)值 bool input()。//輸入函數(shù) bool output()。//輸出函數(shù) void kruskal()。//kruskal算法 void prim()。//prim算法protected: int maxVertices。//圖中最大頂點數(shù) int numEdges。//圖中當(dāng)前邊數(shù) int numVertices。//圖中當(dāng)前頂點數(shù) private: char *VerticesList。//頂點表 int * *Edge。//鄰接矩陣 int visit[50]。//便利時的輔助工具 primnode closeedge[50]。//為實現(xiàn)prim 函數(shù)的輔助結(jié)點}。LJH_Graphmtx::LJH_Graphmtx(int sz)//構(gòu)造函數(shù){ maxVertices=sz。 numVertices=0。 numEdges=0。 int i,j。 VerticesList=new char[maxVertices]。//創(chuàng)建頂點表數(shù)組 Edge=(int * *)new int *[maxVertices]。//創(chuàng)建鄰接矩陣數(shù)組 for(i=0。imaxVertices。i++) Edge[i]=new int[maxVertices]。for(i=0。imaxVertices。i++)//鄰接矩陣初始化 for(j=0。jmaxVertices。j++) Edge[i][j]=(i==j)? 0 : maxWeight。}int LJH_Graphmtx::getFirstNeighbor(int v) { if(v!=1) { for(int i=0。inumVertices。i++) if(Edge[v][i]0amp。amp。Edge[v][i]maxWeight)return i。 } return 1。}int LJH_Graphmtx::getNextNeighbor(int v,int w)//給出頂點v的某鄰接頂點w的下一個鄰接頂點的位置,如果找不到,則函數(shù)返回1{ if(v!=1amp。amp。w!=1) {for(int i=w+1。inumVertices。i++) if(Edge[v][i]0amp。amp。Edge[v][i]maxWeight) return i。 } return 1。}bool LJH_Graphmtx::insertVertex(char vertex)//插入頂點vertex{ if(numVertices==maxVertices) return false。//頂點表滿,不插入 VerticesList[numVertices++]=vertex。 return true。}bool LJH_Graphmtx::inser
點擊復(fù)制文檔內(nèi)容
醫(yī)療健康相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1