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

正文內(nèi)容

[工學(xué)]鏈表綜合學(xué)習(xí)-在線瀏覽

2024-10-01 14:22本頁面
  

【正文】 de結(jié)點(diǎn)插到鏈表頭前面 if((pNodenum)=(pHeadnum)) { pNodenext=pHead。 //將鏈表頭賦值為pNode return。 //r賦值為鏈表頭 q=pHeadnext。 //r指向q所指的結(jié)點(diǎn) q=qnext。 } //將pNode結(jié)點(diǎn)插入正確位置 rnext=pNode。}void print(numST *pHead){ int k=0。 //聲明numST結(jié)構(gòu)指針r,并讓它指向鏈表頭 while(r!=NULL) //鏈表頭指針不為空則循環(huán)繼續(xù) { (2)。 coutk:rnumendl。 //移動至下一個結(jié)點(diǎn) }}int main(){ numST *pMHead=NULL。 //分配3個numST結(jié)構(gòu)的內(nèi)存空間,用于構(gòu)造鏈表 pMNode=new numST。 pMHeadnextnext=new numST。 pMHeadnextnum=10。 pMHeadnextnextnext=NULL。 pMNodenum=12。 insert(pMHead,pMNode)。 return 0。pHead,聲明pHead為numST結(jié)構(gòu)指針的引用,即pHead是“指向numST結(jié)構(gòu)的指針”的引用!主程序中的實(shí)參為鏈表頭指針pMHead的引用,傳給被調(diào)用函數(shù)的pHead,在子函數(shù)中對pHead的操作就等價于對pMHead的操作。pHead,int num){numST *p=NULL,*q=NULL。p=pHead。delete p。}q=pnext。detele q。}if(qnumnum)return。q=qnext。這時先用一個指針p暫存此結(jié)點(diǎn),再讓鏈表頭指向相鄰的下一個結(jié)點(diǎn),最后將p結(jié)點(diǎn)刪除。(3)建立鏈表時,動態(tài)申請的內(nèi)存空間應(yīng)該在程序結(jié)束前釋放,即在程序結(jié)束之前將鏈表中的結(jié)點(diǎn)全部刪除。pHead){numST *p=NULL,*q=NULL。while(p!=NULL){q=pnext。\p=q。 //重要!!將鏈表置空。monkey *next。monkey *head,*tail。monkey *p,*q。pnum=1。head=p。for(i=2。i++){p=new monkey。qnext=p。pnext=NULL。tailnext=head。monkey *p,*q。do{p=qnext。if(x%mm==0){cout被刪除的猴子號為:pnum號!endl。delete p。}else q=p。head=p。head=NULL。cinn。cinm。select(m)。return 0。頭指針head永遠(yuǎn)指向鏈表的第一個結(jié)點(diǎn);對q指針,永遠(yuǎn)讓它指向鏈表的最末一個結(jié)點(diǎn);指針p每次都指向一個待插入的結(jié)點(diǎn),且這個結(jié)點(diǎn)要插到q結(jié)點(diǎn)的后面。(二)學(xué)習(xí)鏈表的插入過程,需要用到4個指針:pHead,pNode,r,q。一開始讓r指向鏈表頭,讓q指向相鄰的下一個結(jié)點(diǎn),即r=pHead。之后就比較pNode結(jié)點(diǎn)和q結(jié)點(diǎn)的num值。說明尚未找到正確的插入點(diǎn)!讓r和q同步后移一個結(jié)點(diǎn),即r=q。如果pNodenum=qnum;則將pNode結(jié)點(diǎn)插入到r結(jié)點(diǎn)后q結(jié)點(diǎn)之前,即rnext=pNode。帶頭結(jié)點(diǎn)單鏈表的C++完整描述includeincludecstdiotemplateclass datatypeclass NODE{ public:datatype data。}。public:LIST(){ head=new NODEdatatype。}。bool isempty(){ return headnext==NULL?true:false。x)。x)。x)。bool insert_data(datatype datd,int i)。bool find_data(datatype x,datatype amp。void print_list()。while(head){ p=head。delete p。templateclass datatypeint LISTdatatype::length(){ int counter=0。current=headnext。counter++。}templateclass datatypebool LISTdatatype::get_data(int i,datatype amp。int j=1。return false。while(current!=NULL){ j++。}x=currentdata。}templateclass datatypebool LISTdatatype::get_succ(int i,datatype amp。int j=1。return false。while(current!=NULLamp。ji){ j++。}if(currentnext!=NULL){ x=currentnextdata。}else{ cout第i個元素?zé)o后繼,不能讀取!endl。}}templateclass datatypebool LISTdatatype::get_prior(int i,datatype amp。int j=1。return false。current=head
點(diǎn)擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1