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

正文內(nèi)容

算法與數(shù)據(jù)結(jié)構(gòu)實(shí)驗(yàn)報(bào)告-在線瀏覽

2024-09-14 05:33本頁(yè)面
  

【正文】 ar next = s。 cin x。 p=headnext。 p=pnext。}void list::insert(elementtype x){ node* u,*P。 while(Pnext!=NULL amp。 Pnextdatax) P=Pnext。 udata=x。 Pnext=u。 }}void main(){ list L。 ()。 cout請(qǐng)輸入要插入的值xendl。 (x)。 }運(yùn)行結(jié)果:X=25X=85X=110X=8,并分別連成一個(gè)帶頭結(jié)點(diǎn)的單鏈表,然后再將這兩個(gè)新鏈表同時(shí)輸出在屏幕上,并保留原鏈表的顯示結(jié)果,以便對(duì)照求解結(jié)果。程序清單:include iostreamusing namespace std。typedef int elementtype 。 struct LinkNode *next。 class list{private: int count。public: list()。public: node * get_head() const {return head。 void display()。list::list(){ head = new node。 count = 0。 node *s,*rear。 rear = head。 s = new node。 s next=NULL。 rear = s。 } }void list::display(){ node *p。 while (p!=NULL){ coutpdata 。 } coutendl。B,list amp。 PB=()。 PA = () next。 sdata=PAdata。 PB=s。 PA=PAnext。 sdata=PAdata。 PC=s。 PA=PAnext。 ()。 cout原鏈表:endl。 cout偶鏈表:endl。 cout奇鏈表:endl。實(shí)驗(yàn)結(jié)果:第一組數(shù)據(jù):第二組數(shù)據(jù):1. 求兩個(gè)遞增有序鏈表L1和L2中的公共元素,并以同樣方式連接成鏈表L3。在pa,pb均非空時(shí),根據(jù)其值的大小關(guān)系可能有如下三種情況。(1).padata==pbdata:搜索到公共元素,應(yīng)在C表表尾插入一個(gè)結(jié)點(diǎn),其值為padata,然后繼續(xù)A表中下一個(gè)元素的搜索,即pa=panext,同時(shí)pb也往后移。padatapbdata:表明A表中這一元素可能在B表當(dāng)前元素的后面,因此要往B表的后面搜索,故而執(zhí)行pb=pbnext,然后繼續(xù)搜索。padatapbdata:表明A中這一元素在B中不存在,因而執(zhí)行pa=panext以繼續(xù)對(duì)A表中下一個(gè)元素的判斷。此時(shí),剩余的非空部分沒(méi)有所需要的公共元素,因而搜索結(jié)束。typedef struct snode{int data。}node。class list{public:list()。int length() const。x) const。x)。node *locate(const int x) const。}void list::gongyou(list amp。L2)void print()。node *head。list::list(){head=new node。count=0。 node *p=head。 cout輸入一個(gè)值:。while(x!=1){s=new node。snext=NULL。p=s。cinx。}error_code list::get_element(const int i,int amp。 node *p=headnext。amp。 j++。x=pdata。}void list::gongyou(list amp。L2){node *p1=next。node *p3=head。while(p1!=NULLamp。p2!=NULL){if(p1data==p2data){u=new node。 p3next=u。 p2=p2next。}else{if(p1datap2data)p1=p1next。}}p3next=NULL。while(p!=NULL){if(pdata==x)return p。}return NULL。B,list amp。 node *pa=headnext。 node *pc=()。pa!=NULL。 udata=padata。 pb=pbnext。 pc=pcnext。 pcnext=NULL。x){node *s。 node *p=headnext。amp。 p=pnext。 sdata=x。 qnext=s。 }else{s=new node。 snext=qnext。 count++。}error_code list::delete_element(const int i){node *u。 int j=0。amp。 j++。u=pnext。delete u。return success。while(p!=NULL){coutpdata 。}coutendl。()。 (L1,L2)。 ()。第一組數(shù)據(jù):第二組數(shù)據(jù):實(shí)驗(yàn)三 二叉樹(shù)實(shí)驗(yàn)?zāi)康模赫莆斩鏄?shù)的動(dòng)態(tài)鏈表存儲(chǔ)結(jié)構(gòu)及表示。運(yùn)用二叉樹(shù)三種遍歷的方法求解有關(guān)問(wèn)題。實(shí)驗(yàn)任務(wù)二:分別對(duì)該二叉樹(shù)進(jìn)行先序、中序和后序遍歷。實(shí)驗(yàn)任務(wù)四:設(shè)計(jì)算法輸出二叉樹(shù)的先序序列的前k(k0)個(gè)結(jié)點(diǎn)的值。對(duì)二叉樹(shù)的遍歷是在對(duì)各子樹(shù)分別遍歷的基礎(chǔ)之上進(jìn)行的。程序清單:include iostreamusing namespace std。typedef struct bitree{ elementtype data。 } bnode。 void preorder(){preorder(root)。} void postorder(){postorder(root)。} int high(){return high(root)。}private: bnode * root。 void preorder(bnode *T)。 void postorder(bnode *T)。T)。 int num( bnode *T )。BinaryTree::BinaryTree(){ root=NULL。}void BinaryTree::preorder(bnode *T){ if(T!=NULL) { int n=0。 coutn。 preorder(Tlchild)。 }}void BinaryTree::inorder(bnode *T){ if(T!=NULL) { inorder(Tlchild)。 inorder(Trchild)。 postorder(Trchild)。 } }void BinaryTree::CreateBitree(bnode *amp。 cinch。39。 else { T=new bnode。 CreateBitree(Tlchild)。 }}int max(int a,int b){ if(a=b) return b。}int BinaryTree::high( bnode *T ){ if ( T == NULL ) return(0)。 }int BinaryTree::num( bnode * T ) { if ( T == NULL ) return(0)。 }void main(){ BinaryTree t。 ()。()。 cout中序序列: 。 coutendl。()。 cout二叉樹(shù)的高度為: ()。 cout結(jié)點(diǎn)數(shù)為: ()。}運(yùn)行結(jié)果:實(shí)驗(yàn)四 圖實(shí)驗(yàn)?zāi)康模?。,以及遍歷算法的應(yīng)用。2. 對(duì)圖進(jìn)行深度優(yōu)先遍歷(廣度優(yōu)先遍歷)。4. 判斷無(wú)向圖是否是連通的。因此,對(duì)有n個(gè)頂點(diǎn)的圖來(lái)說(shuō),其鄰接矩陣A為n*n階的,其中Aij表示頂點(diǎn)vi到vj之間是否有邊或?。喝舸嬖?,則Aij為1,否則為0。在執(zhí)行遍歷dfs(v)時(shí),搜索下一個(gè)訪問(wèn)頂點(diǎn)是從當(dāng)前訪問(wèn)頂點(diǎn)v的鄰接表中搜索的,因此,每搜索到一個(gè)鄰接點(diǎn)即意味著搜索到一條以v為一個(gè)端點(diǎn)的邊或弧,故應(yīng)在dfs算法中計(jì)數(shù)。typedef int elementtype 。int E。class graph{ public: graph( )。 void dfs(elementtype v)。 int firstadj(elementtype v)。 int numofGC()。 int CurrentVertex。 int edge[MaxVertex][MaxVertex]。graph::graph(){ int i,j。iMaxVertex。 for(i=0。i++) for(j=0。j++) edge[i][j]=0。 cout請(qǐng)輸入頂點(diǎn)
點(diǎn)擊復(fù)制文檔內(nèi)容
研究報(bào)告相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1