




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、1、現(xiàn)有 1000 個(gè)蘋果,10 個(gè)盒子,問各個(gè)盒子內(nèi)應(yīng)該分別放入多少個(gè)蘋果,才能使得用戶要買任意 1 至 1000 之間的一個(gè)蘋果數(shù),都可以給他(賣的時(shí)候是整個(gè)盒子賣,不能拆盒子的包裝)。2、請仔細(xì)閱讀下面的資料:1)材料一:CArraytemplate class CArray : publicCObjectParameters:TYPETemplate parameter specifying the type of objects stored in the array.TYPE is a parameter that is returned by CArray.ARG_TYPETem
2、plate parameter specifying the argument type used to access objectsstored in the array.Often a reference to TYPE. ARG_TYPE is a parameter that is passed toCArray.Remarks:The CArray class supports arrays that are are similar to C arrays, but candynamically shrink and grow as necessary.Array indexes a
3、lways start at position 0. You can decide whether to fixthe upper bound or allow the array to expand when you add elements pastthe current bound. Memory is allocated contiguously to the upper bound,even if some elements are CArray:Add (ARG_TYPE newElement);Return Value:The index of the adde
4、d element.Parameters:ARG_TYPETemplate parameter specifying the type of arguments referencingelements in this array.newElementThe element to be added to this array.TYPE& CArray:operator (int nIndex);Parameters:TYPETemplate parameter specifying the type of elements in this array.nIndexIndex of the ele
5、ment to be accessed.Remarks:Returns the array reference of element at the specified index.2)材料二:CListtemplateclass CList : public CObjectParameters:TYPEType of object stored in the list.ARG_TYPEType used to reference objects stored in the list. Can be a reference.Remarks:The CList class supports ord
6、ered lists of nonunique objects accessiblesequentially or by value.CList lists behave like doubly-linked lists.void CList:AddTail(ARG_TYPE newElement);Parameters:ARG_TYPETemplate parameter specifying the type of the list element (can be areference).newElementThe element to be added to this list.Rema
7、rks:Adds a new element or list of elements to the tail of this list. The list canbe empty before the operation.3)材料三: reallocreallocReallocate memory blocks.void *realloc(void *memblock, size_t size);Return Value:The return value points to a storage space that is guaranteed to be suitablyaligned for
8、 storage of any type of object. To get a pointer to a type otherthan void, use a type cast on the return value.Remarks:The size argument gives the new size of the block, in bytes. The contentsof the block are unchanged up to the shorter of the new and old sizes,although the new block can be in a dif
9、ferent location. Because the newblock can be in a new memory location, the pointer returned by realloc isnot guaranteed to be the pointer passed through the memblock argument.4)請指出下面這段代碼可能會出現(xiàn)的問題CList g_ValueList;CArray g_ValuePool;void AddNewValue (const VARIANT& newValue)g_ValueList.AddTail(&g_Valu
10、ePoolg_ValuePool.Add(newValue);3、有一無符號整型數(shù)組,大小為 10, 初始的數(shù)值隨機(jī),但在0, 99之間。請用 C 語言寫一個(gè)過濾程序,令數(shù)組內(nèi)的數(shù)據(jù)互不相等。說明:1.若數(shù)組內(nèi)有相等的數(shù)據(jù),可令某一數(shù)值加 1 或減 1 作出偏移,直至不等為止。2.數(shù)組內(nèi)的數(shù)據(jù)只能在0, 99之間。3.保持?jǐn)?shù)組內(nèi)的數(shù)據(jù)位置不變,即對應(yīng)下標(biāo)不變。4、 按要求編寫以下函數(shù)。功能:將給定緩沖區(qū)中的#字符移到字符串尾部函數(shù)名稱:ChangeToTail入口參數(shù):pSZ 指向緩沖區(qū)的指針, nSize 緩沖區(qū)長度出口:pSZ 所指緩沖區(qū)中的#字符被移到緩沖區(qū)尾部返回值:在出口緩沖區(qū)中第一
11、個(gè)#的位置,若緩沖區(qū)中無#字符則返回-1說 明 : 如 傳 入 #W#W#W#WW# , 10 則 傳 出 時(shí) 應(yīng) 轉(zhuǎn) 換 為WWWWW#并且返回值為 5int ChangeToTail(BYTE* pSZ, UINT nSize)/ Todo:請?jiān)诖思尤肽拇a5、在金山,有一個(gè)非常經(jīng)典有趣的游戲,稱為殺人游戲。此游戲角色有:好人(m 人)、壞人(n 人)、村長(1 人)、裁判(1 人)。角色采用一定方式(如:抓鬮)分配。村長、裁判兩個(gè)角色是公開的,而好人、壞人兩個(gè)角色則只要裁判和本人心知肚明。其玩法如下:游戲開始了,裁判說:“天黑了”,這是所有其他角色都低頭閉上眼睛(不準(zhǔn)作弊?。?。然后裁判
12、說:“壞人開始活動”,此時(shí)壞人抬起頭,并相互商議,殺死一個(gè)好人。然后裁判說:“天亮了”,此時(shí)所有人抬頭,被殺死的那個(gè)好人宣布出局。剩下的人在村長的主持下,開始判斷殺人兇手。每個(gè)人可以根據(jù)各人的表情反應(yīng),判斷并提議殺死自己心目中的壞人。不過最終的裁決權(quán)屬于村長,綜合大家的意見殺死一人。此時(shí)裁判宣布此人出局。游戲進(jìn)入下一輪,由天黑到天亮,再有2 人出局,如此反復(fù),直到最后好人先被全部殺死,則游戲結(jié)束,“邪惡”的一方戰(zhàn)勝了“正義”的一方;而另一個(gè)結(jié)局則是在大家以及村長的英明決斷下,壞人被全部殺死,則“正義”的一方戰(zhàn)勝了“邪惡”的一方?,F(xiàn)在,我們的問題是,請寫出你的思路,并編寫一個(gè) C/C+語言程序,
13、求出:在壞人有兩個(gè)(n = 2)的情況下,需要多少個(gè)好人(m = ?),才能夠使這個(gè)游戲比較公平,也就是說,從概率上說,“正義”的一方與“邪惡”的一方勝利的幾率最接近于 50%。(此題與下面一題選做一道)6、在以上的殺人游戲中,還有一個(gè)玩法,就是取消村長這個(gè)角色,“天亮”后剩余的人每個(gè)人投票列出自己心目中最懷疑的 2 個(gè)人,以此決定讓誰出局。試問,在此玩法下,上面的問題又何解?7.C+程序設(shè)計(jì)1).寫出以下程序的運(yùn)行結(jié)果:#include class Basepublic:Base()cout Base() endl;Base(const Base &theBase)cout Base(const Base &theBase) endl;Base()cout Base() endl;void Open()OnOpen();private:virtual void OnOpen() = 0;class Derived : public Basepublic:Derived()cout Derived() endl;Derived(const Derived &theDerived)cout Deriv
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T-ZRCMA 001-2024 城市軌道交通智慧實(shí)訓(xùn)系統(tǒng)技術(shù)規(guī)范
- 二零二五年度餐飲店面租賃合同含節(jié)假日促銷活動
- 二零二五年度個(gè)人擔(dān)保合同-個(gè)人理財(cái)產(chǎn)品擔(dān)保服務(wù)條款
- 二零二五年度農(nóng)村墓地選購與祭祀活動組織合同
- 二零二五年度茶飲品牌全國使用許可合同
- 二零二五年度互聯(lián)網(wǎng)保險(xiǎn)產(chǎn)品銷售委托理財(cái)服務(wù)協(xié)議
- 二零二五年度棋牌室合作伙伴關(guān)系管理與維護(hù)合同
- 2025年度順豐員工勞動合同爭議解決機(jī)制合同
- 二零二五年度個(gè)人合同范本:智能家居控制系統(tǒng)研發(fā)合作合同
- 二零二五年度新型工業(yè)園區(qū)委托中介代理出租服務(wù)協(xié)議
- 2025年高考百日誓師大會校長致辭(二)
- 2025年河南機(jī)電職業(yè)學(xué)院單招職業(yè)技能測試題庫及參考答案
- 2025年黑龍江能源職業(yè)學(xué)院單招職業(yè)傾向性測試題庫完整
- 學(xué)校垃圾處理運(yùn)輸服務(wù)合同
- 廣西2025年01月南寧市良慶區(qū)公開考試招考專職化城市社區(qū)工作者筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 注塑產(chǎn)品生產(chǎn)流程
- 統(tǒng)編版(2025)七年級下冊道德與法治教學(xué)計(jì)劃
- 七年級數(shù)學(xué)下冊 第11章 單元測試卷(蘇科版 2025年春)
- 2024年天津市建筑安全員A證考試題庫及答案
- 2021年江蘇省公務(wù)員考試行測+申論真題及答案解析(A類卷)
- 2024年皖西衛(wèi)生職業(yè)學(xué)院單招職業(yè)適應(yīng)性測試題庫及答案解析
評論
0/150
提交評論