Ex3-23 親兄弟問(wèn)題
« 問(wèn)題描述:
給定n 個(gè)整數(shù)0 1 1 , , , n- a a a 組成的序列。序列中元素i a 的親兄弟元素k a 定義為:
min{ | } k i j n j j i a = a a ³ a
< <
。
親兄弟問(wèn)題要求給定序列中每個(gè)元素的親兄弟元素的位置。元素i a 的親兄弟元素為k a
時(shí),稱k 為元素i a 的親兄弟元素的位置。當(dāng)元素i a 沒(méi)有親兄弟元素時(shí),約定其親兄弟元素
的位置為-1。
例如,當(dāng)n=10,整數(shù)序列為6,1,4,3,6,2,4,7,3,5 時(shí),相應(yīng)的親兄弟元素位
置序列為:4,2,4,4,7,6,7,-1,9,-1。
« 編程任務(wù):
對(duì)于給定的n個(gè)整數(shù)0 1 1 , , , n- a a a 組成的序列,試用抽象數(shù)據(jù)類型棧,設(shè)計(jì)一個(gè)O(n)
時(shí)間算法,計(jì)算相應(yīng)的親兄弟元素位置序列。
« 數(shù)據(jù)輸入:
由文件input.txt提供輸入數(shù)據(jù)。文件的第1 行有1 個(gè)正整數(shù)n,表示給定給n個(gè)整數(shù)。
第2 行是0 1 1 , , , n- a a a 。
« 結(jié)果輸出:
程序運(yùn)行結(jié)束時(shí),將計(jì)算出的與給定序列相應(yīng)的親兄弟元素位置序列輸出到output.txt
中。
輸入文件示例 輸出文件示例
input.txt
10
4 2 4 4 7 6 7 -1 9 -1
output.txt
6 1 4 3 6 2 4 7 3 5
標(biāo)簽:
61516
laquo
min
序列
上傳時(shí)間:
2013-12-17
上傳用戶:shizhanincc
為適應(yīng)雙向DC/DC功率變換的電流采樣需求,一種高精度高邊電流采樣電路被提出。其基本思想是在功率電路的高邊串入采樣電阻,借助電流鏡原理并引入偏置電流電路,將雙向電流均轉(zhuǎn)換為正向電壓輸出。通過(guò)理論分析與仿真結(jié)合的方法對(duì)電流鏡采樣原理及4種不同的偏置電流電路方案進(jìn)行對(duì)比,最后通過(guò)實(shí)驗(yàn)數(shù)據(jù)驗(yàn)證了高精度高邊電流采樣電路的有效性。實(shí)驗(yàn)數(shù)據(jù)表明,該采樣電路可在-25~75℃的溫度工作范圍內(nèi),針對(duì)-10~+10 A范圍內(nèi)的電流采樣實(shí)現(xiàn)優(yōu)于5%的采樣精度。Current sensing plays an important role in controlling,monitoring or protection functions of power systems.To meet the current sensing requirement of bidirectional DC/DC converters,a high-accuracy bidirectional current sensing circuit is proposed.The proposed current sensing circuit inserts a resistor in the path of the current to be sensed,while the current mirror and biased current circuit are introduced.Therefore,the bidirectional current can be expressed by positive voltage.By theoretical analysis and simulation,the sampling theory is analyzed and four biased current circuits are compared.At last,experimental results verified the proposed method.It is demonstrated that the proposed current sensing circuit can achi...
標(biāo)簽:
雙向DC電源
電流采樣
上傳時(shí)間:
2022-04-22
上傳用戶: