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

正文內(nèi)容

經(jīng)典數(shù)據(jù)結(jié)構(gòu)面試題含答案-資料下載頁

2025-06-19 07:56本頁面
  

【正文】 nese site: 。 coutreverse(This is fishsky39。s Chinese site: ://. , fishsky )。 return 0。} 8, 刪除數(shù)組中重復(fù)的數(shù)字 問題:一個動態(tài)長度可變的數(shù)字序列,以數(shù)字0為結(jié)束標(biāo)志,要求將重復(fù)的數(shù)字用一個數(shù)字代替,例如:將數(shù)組 1,1,1,2,2,2,2,2,7,7,1,5,5,5,0 轉(zhuǎn)變成1,2,7,1,5,0 問題比較簡單,要注意的是這個數(shù)組是動態(tài)的。所以避免麻煩我還是用了STL的vector。include iostreaminclude vectorusing namespace std。//remove the duplicated numbers in an intger array, the array was end with 0。//. 1,1,1,2,2,5,4,4,4,4,1,0 1,2,5,4,1,0void static remove_duplicated(int a[], vectorintamp。 _st){ (a[0])。 for(int i=1。_st[()1]!=0。i++) { if(a[i1]!=a[i]) (a[i])。 }}當(dāng)然如果可以改變原來的數(shù)組的話,可以不用STL,僅需要指針操作就可以了。下面這個程序?qū)⑿薷脑瓉頂?shù)組的內(nèi)容。void static remove_duplicated2(int a[]){ if(a[0]==0 || a==NULL) return。 int insert=1,current=1。 while(a[current]!=0) { if(a[current]!=a[current1]) { a[insert]=a[current]。 insert++。 current++。 } else current++。 } a[insert]=0。} 9,如何判斷一棵二叉樹是否是平衡二叉樹 問題:判斷一個二叉排序樹是否是平衡二叉樹 解決方案:根據(jù)平衡二叉樹的定義,如果任意節(jié)點(diǎn)的左右子樹的深度相差不超過1,那這棵樹就是平衡二叉樹。首先編寫一個計算二叉樹深度的函數(shù),利用遞歸實現(xiàn)。templatetypename Tstatic int Depth(BSTreeNodeT* pbs){ if (pbs==NULL) return 0。 else { int ld = Depth(pbsleft)。 int rd = Depth(pbsright)。 return 1 + (ld rd ? ld : rd)。 }}下面是利用遞歸判斷左右子樹的深度是否相差1來判斷是否是平衡二叉樹的函數(shù):templatetypename Tstatic bool isBalance(BSTreeNodeT* pbs){ if (pbs==NULL) return true。 int dis = Depth(pbsleft) Depth(pbsright)。 if (dis1 || dis1 ) return false。 else return isBalance(pbsleft) amp。amp。 isBalance(pbsright)。 class Something { private abstract String doSomething ()。 } 該段代碼有錯嗎? 答案: 錯。abstract的methods不能以private修飾。abstract的methods就是讓子類implement(實現(xiàn))具體細(xì)節(jié)的,怎么可以用private把a(bǔ)bstract method封鎖起來呢? (同理,abstract method前不能加final)。 ? public class Something { void doSomething () { private String s = 。 int l = ()。 } } 答案: 錯。局部變量前不能放置任何訪問修飾符 (private,public,和protected)。final可以用來修飾局部變量 (final如同abstract和strictfp,都是非訪問修飾符,strictfp只能修飾class和method而非variable)。 6. 下面該段代碼是否有錯,若是有錯錯在哪里? abstract class Name { private String name。 public abstract boolean isStupidName(String name) {} } 答案: 錯。abstract method必須以分號結(jié)尾,且不帶花括
點(diǎn)擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1