![2015年電大面向?qū)ο蟪绦蛟O(shè)計(jì)作業(yè)答案參考資料小抄_第1頁(yè)](http://file.renrendoc.com/FileRoot1/2015-1/18/f0094cbd-b751-4e6d-9680-cb59a1826672/f0094cbd-b751-4e6d-9680-cb59a18266721.gif)
![2015年電大面向?qū)ο蟪绦蛟O(shè)計(jì)作業(yè)答案參考資料小抄_第2頁(yè)](http://file.renrendoc.com/FileRoot1/2015-1/18/f0094cbd-b751-4e6d-9680-cb59a1826672/f0094cbd-b751-4e6d-9680-cb59a18266722.gif)
![2015年電大面向?qū)ο蟪绦蛟O(shè)計(jì)作業(yè)答案參考資料小抄_第3頁(yè)](http://file.renrendoc.com/FileRoot1/2015-1/18/f0094cbd-b751-4e6d-9680-cb59a1826672/f0094cbd-b751-4e6d-9680-cb59a18266723.gif)
![2015年電大面向?qū)ο蟪绦蛟O(shè)計(jì)作業(yè)答案參考資料小抄_第4頁(yè)](http://file.renrendoc.com/FileRoot1/2015-1/18/f0094cbd-b751-4e6d-9680-cb59a1826672/f0094cbd-b751-4e6d-9680-cb59a18266724.gif)
![2015年電大面向?qū)ο蟪绦蛟O(shè)計(jì)作業(yè)答案參考資料小抄_第5頁(yè)](http://file.renrendoc.com/FileRoot1/2015-1/18/f0094cbd-b751-4e6d-9680-cb59a1826672/f0094cbd-b751-4e6d-9680-cb59a18266725.gif)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
一、編程題。根據(jù)程序要求,寫(xiě)出函數(shù)的完整定義。 ( 40 分) 1寫(xiě)一個(gè)函數(shù),找出給定字符串中大寫(xiě)字母字符(即 A - Z這 26 個(gè)字母)的個(gè)數(shù)(如字符串” China Computer Wrold”中大寫(xiě)字母字符的個(gè)數(shù)為 3 個(gè))。 函數(shù)的原型: int CalcCapital (char *str); 函數(shù)參數(shù): str 為所要處理的字符串; 函數(shù)返回值:所給字符串中數(shù)字字符的個(gè)數(shù) 答: int CalcCapital (char *str) if (str = NULL) return 0; /判斷字符指針是否為空 int num_of_Capital = 0; /記錄大寫(xiě)字母字符個(gè)數(shù)的變量,初值為 0 for(int i=0; stri != 0x0; i+) if (stri = Z) num_of_ Capital +; /若是大寫(xiě)字母,則總數(shù)加 1 return num_of_ Capital; /返回大寫(xiě)字母字符數(shù) 2寫(xiě)一個(gè)函數(shù),用遞歸函數(shù)完成以下運(yùn)算 : sum(n) = 1 1/2 + 1/3 1/4 + -(1/n)*(-1)n (其中 n0) 函數(shù)原型: float sum(int n); 函數(shù)參數(shù): n 為正整數(shù)。 函數(shù)返回值:相應(yīng)于給定的 n,右邊表達(dá)式運(yùn)算結(jié)果。 提示:你可以使用遞歸表達(dá)式: sum(n) = sum(n-1) -(1/n)*(-1)n 答: float sum(int n) if (n = 1) return 1; else return sum(n-1) -(1.0/n)*(-1)n; 3. 給定新數(shù)值,在一個(gè)按節(jié)點(diǎn)所存放數(shù)值從大到小排序的鏈表中,找適當(dāng)位置插一個(gè)新節(jié)點(diǎn),仍保持有序的鏈表,寫(xiě)一個(gè)函數(shù),完成此操作。 函數(shù)的原型: Node * InsNode(Node * head, int newValue); 其中,鏈表節(jié)點(diǎn)的定義如下: struct Nodee int Value; /存放數(shù)值 Node * next; /指向鏈表中的下一個(gè)節(jié)點(diǎn) ; 函數(shù)參數(shù):函數(shù)的第一個(gè)參數(shù) head 指向鏈表頭一節(jié)點(diǎn)的指針,如果鏈表為 空,則 head 的值為 NULL。第二個(gè)參數(shù)newValue 為所給定的插入新節(jié)點(diǎn)的新數(shù)值。 函數(shù)返回值:當(dāng)成功地插入新的節(jié)點(diǎn)時(shí),函數(shù)返回指向新鏈表頭一節(jié)點(diǎn)的指針,否則,若不能申請(qǐng)到內(nèi)存空間,則返回 NULL。 答: Node * insNode(Node * head, int newValue) Node * newNode = new Node; /申請(qǐng)新的節(jié)點(diǎn)空間 if (newNode = NULL) return NULL;/ newNode-data = newValue; /填充新節(jié)點(diǎn)的內(nèi)容 newNode-next = NULL; Node *pre, *cur; Pre = head; if (head = NULL) head = newNode; /插入到空鏈表的表頭 else if(newValue=head-Value) newNode-next=head; head = newNode; /插入到鏈表的表頭 else /在鏈 表尋找插入點(diǎn) Node *cur,*pre = head; while(pre-next != NULL) cur = pre-next; if(newValue = cur-Value) break; else pre = cur; if(pre-next!= NULL) newNode-next = cur;/若非末尾,則有下一節(jié)點(diǎn) pre-next = newNode; /將新節(jié)點(diǎn)插入 return head; 4寫(xiě)一個(gè)函數(shù),找出給定數(shù)組中具有最小值的元素。 函數(shù)的原型: char MinCode(char charAry); 函數(shù)參數(shù): charAry 所要處理的字符數(shù)組名; 函數(shù)返回值:返回具有最小 ASCII 碼的字符。 答: char MinCode(char charAry,int len=10) char mixCode = 0x0; for(int i=0; i len; i+) if (charAry i mixCode) mixCode = stri; return mixCode; 二、理解問(wèn)答題: ( 20 分) 下面的文件 stack.h 是一個(gè)堆棧類模板 Stack 的完整實(shí)現(xiàn)。在這個(gè)文件中,首先定義了一個(gè)堆棧元素類模板 StackItem,然后,在這個(gè)類的基礎(chǔ)上定義了堆棧類模板 Stack。在 Stack 中使用鏈表存放堆棧的各個(gè)元素, top 指針指向鏈表的第一個(gè)節(jié)點(diǎn)元素, bottom 指針指向鏈表的最后一個(gè)節(jié)點(diǎn)元素,成員函數(shù) push()將一個(gè)新節(jié)點(diǎn)元素加入(壓進(jìn))到堆棧頂部, pop()從堆棧頂部刪除(彈出)一個(gè)節(jié)點(diǎn)元素。為方便起見(jiàn),程序中加上了行號(hào)。閱讀程序,根據(jù)程序后面的問(wèn)題作出相應(yīng)解答。 1. /*-*/ 2. /* 文件 stack.h */ 3. /*-*/ 4. template 5. class Stack; 6. /* 定義模板類 StackItem */ 7. template 8. class StackItem 9. 10. public: 11. StackItem(const Type & elem):item(elem) 12. StackItem() 13. private: 14. Type item; 15. StackItem * nextItem; 16. friend class Stack; 17. ; 18. /* 定義模板類 Stack */ 19. template 20. class Stack 21. 22. public: 23. Stack():top( NULL), _(A)_ 24. Stack(); 25. Type pop(); 26. void push(const Type &); 27. bool is_empty() const return _(B) _ ; 28. private: 29. StackItem * top; 30. StackItem * bottom; 31. ; 32. /模板類 Stack 的函數(shù)成員 pop()的實(shí)現(xiàn)。 33. /從堆棧頂彈出一個(gè)節(jié)點(diǎn),并返回該節(jié)點(diǎn)的值 34. template 35. Type Stack:pop() 36. 37. StackItem *ptop; /指向頂部節(jié)點(diǎn)的臨時(shí)指針 38. Type retVal; /返回值 39. _(C) _; 40. retVal = top-item; 41. top = top-nextItem; 42. delete ptop; 43. return retVal; 44. 45. /模板類 Stack 的函數(shù)成員 push()的實(shí)現(xiàn) 46. template 47. void Stack:push(const Type & newItem) 48. 49. StackItem *pNew = new StackItem( newItem); 50. _(D)_; 51. if (bottom = NULL) bottom = top = pNew; 52. else _(E)_; 53. 54. /模板類 Stack 的析構(gòu)函數(shù) Stack()的實(shí)現(xiàn) 55. template 56. Stack:Stack() 57. 58. StackItem *p = top, *q; 59. while(p != NULL) 60. q = p-nextItem; 61. delete p; 62. p = q; 63. 64. 問(wèn)題 1: 程序中有幾處填空,將它們完成。 ( A) bottom (NULL) ( B) top = NULL; ( C) ptop = top; ( D) pNew-nextItem = top; ( E) top = pNew; 問(wèn)題 2:程序第 4, 5 行有什么作用?如果沒(méi)有這兩行語(yǔ)句,程序還正確嗎? 答: 不正確。因?yàn)轭?StackItem 模板類的定義中用到了模板類 Stack, Stack 還沒(méi)有定義,所以,必須先聲明 Stack 是一個(gè)模板類,否則 ,編譯程序就不知道標(biāo)識(shí)符 Stack 代表什么樣的含義,無(wú)法進(jìn)行編譯。 問(wèn)題 3:程序中多處出現(xiàn) const,請(qǐng)分別說(shuō)明它們各自表示什么含義。 答:第 11、 26 和 47 行的 const 修飾的都是函數(shù)的參數(shù),表示在這個(gè)函數(shù)體中不能改它所修飾的參數(shù)的值。第 27 行的 const修飾的是模板類 Stack 的成員函數(shù) is_empty(),它表示在函數(shù) is_empty()的函數(shù)體中不能改變?nèi)魏螖?shù)據(jù)成員的值。 問(wèn)題 4:程序中模板類 Stack 的析構(gòu)函數(shù)主要做了什么事情?為什么要這么做? 答: 析構(gòu)函數(shù)中主要是釋放存放的各個(gè)節(jié)點(diǎn)所 占涌空間。因?yàn)?Stack 對(duì)象在其生存期間可能加入了很多節(jié)點(diǎn),從堆中申請(qǐng)了一些內(nèi)存空間。這些空間應(yīng)隨著對(duì)象的消亡而釋放掉,所以,需要在析構(gòu)函數(shù)中釋放這些空間。 問(wèn)題 5:下面的程序使用了 stack.h 文件中定義的類模板,請(qǐng)說(shuō)明下列程序中定義堆棧對(duì)象的語(yǔ)句 (1-5)是否正確。 #include “stack.h” void main() Stack q1; / 1 Stack q2; / 2 Stack q3(10); / 3 Stack q410; / 4 Stack *q5 = new Stack; / 5 /. delete q5; 答: 語(yǔ)句號(hào) 1 2 3 4 5 對(duì) /錯(cuò) 錯(cuò) 對(duì) 錯(cuò) 錯(cuò) 對(duì) 三、 填空題 ( 20 分 ) 下面是一個(gè)求數(shù)組元素之和的程序。主程序中定義了并初始化了一個(gè)數(shù)組,然后計(jì)算該數(shù)組各元素的和,并輸出結(jié)果。函數(shù) sum 計(jì)算數(shù)組元素之和。填充程序中不完整的部分。 _a_. int sum(int ,int); void main() int ia5 = 2,3,6,8,10; b ; sumofarray = sum(ia,5); cout sum of array: sumofarray endl; int sum(int array,int len) int isum = 0; for(int i = 0; c ; d ) e ; return isum; A:#include B: int sumofarray=0; C:ilen D:i+ E:iSum+=arrayi 四、 綜合編程題 ( 20 分) 定義一個(gè)日期類 date,該類對(duì)象存放一個(gè)日期,可以提供的操作有: int getyear ();/取年份 int getmonth ();/取月份 int getday ();/取日子值 void setdate (int year, int month, int day);/設(shè)置日期值 下面是測(cè)試你所定義的日期類程序: #include #include “date.h” void main() date d1(1999, 1, 14);/用所給日期定一個(gè)日期變量 date d2; /定義一個(gè)具有缺省值為 1980 年 1 月 1 日的日期 , date d3(d1);/用已有日期 x 構(gòu)造一個(gè)新對(duì)象 d2.setdate(1999,3,13); cout date:; cout d1.getyear() . d1.getmonth() . d1.getday() endl; cout date:; cout d2.getyear() . d2.getmonth() . d2.getday() endl; cout date:; cout d3.getyear() . d3.getmonth() . d3.getday() endl; 寫(xiě)出日期類的完整定義,其 ,三個(gè) get 函數(shù)寫(xiě)成內(nèi)聯(lián)函數(shù)形式 ,setdate 寫(xiě)成非內(nèi)聯(lián)函數(shù)形式。所有數(shù)據(jù)成員都定義為私有成員。注意構(gòu)造函數(shù)的三種形式。 寫(xiě)出程序的運(yùn)行結(jié)果。 修改程序,在日期類中定義日期的輸出函數(shù),這樣,主程序就可以簡(jiǎn)化。輸出格式和上面一樣。只需要寫(xiě)出類date 的修改部分。 簡(jiǎn)化后主程序如下: void main() date d1(1999, 1, 14); date d2; date d3(d1); d2.setdate(1999,3,13); d1.print(); d2.print(); d3.print(); 答: class Date private:int year,month,day; public:Data(int yr,int mth,int dy):year(yr),month(mth),day(dy); Date():year(1980),month(1),day(1); Date(date&d1):year(d1.year),month(d1.month),day(d1.day); int GetYear()return year; int GetMonth()return month; int GetDay()return day; void SetDate(int yr,int mth,int dy); ; void Date:SetDate(int yr,int mth,int dy) year=yr; month=mth; day = dy; 程序運(yùn)行結(jié)果 Date:1999.1.14 Date:1999.3.13 Date:1999.1.14 修改部分: class Date public:void Print(); void Date:Print()cout”Date”;coutyear.month.dayendl; 面向?qū)ο蟪绦蛟O(shè)計(jì) 大作業(yè) 班級(jí) : 學(xué)號(hào): 姓名: 請(qǐng)您刪除一下內(nèi)容, O( _ )O 謝謝! 2015 年中央電大期末復(fù)習(xí)考試小抄大全,電大期末考試必備小抄,電大考試必過(guò)小抄 After earning his spurs in the kitchens of The Westin, The Sheraton, Sens on the Bund, and a sprinkling of other top-notch venues, Simpson Lu fi nally got the chance to become his own boss in November 2010. Sort of. The Shanghai-born chef might not actually own California Pizza Kitchen (CPK) but he is in sole charge of both kitchen and frontof- house at this Sinan Mansionsstalwart. Its certainly a responsibility to be the head chef, and then to have to manage the rest of the restaurant as well, the 31-year-old tells Enjoy Shanghai. In hotels, for example, these jobs are strictly demarcated, so its a great opportunity to learn how a business operates across the board. It was a task that management back in sunny California evidently felt he was ready for, and a vote of confi dence from a company that, to date, has opened 250 outlets in 11 countries. And for added pressure, the Shanghai branch was also CPKs China debut. For sure it was a big step, and unlike all their other Asia operations that are franchises, they decided to manage it directly to begin with, says Simpson. Two years ago a private franchisee took over the lease, but the links to CPK headquarters are still strong, with a mainland-based brand ambassador on hand to ensure the business adheres to its ethos of creating innovative, hearth-baked pizzas, a slice of PR blurb that Simpson insists lives up to the hype. They are very innovative, he says. The problem with most fast food places is that they use the same sauce on every pizza and just change the toppings. Every one of our 16 pizza sauces is a unique recipe that has been formulated to complement the toppings perfectly. The largely local customer base evidently agrees and on Saturday and Sunday, at least, the place is teeming. The kids-eat-for-free policy at weekends is undoubtedly a big draw, as well as is the spacious second-fl oor layout overlooked by a canopy of green from Fuxing Park over the road. The company is also focusing on increasing brand recognition and in recent years has taken part in outside events such as the regular California Week. Still, the sta are honest enough to admit that business could be better; as good, in fact, as in CPKs second outlet in the popular Kerry Parkside shopping mall in Pudong. Sinan Mansions has really struggled to get the number of visitors that were envisaged when it first opened, and it hasnt been easy for any of the tenants here, adds Simpson. Were planning a third outlet in the city in 2015, and we will probably choose a shopping mall again because of the better foot traffic. The tearooms once frequented by Coco Chanel and Marcel Proust are upping sticks and coming to Shanghai, Xu Junqian visits the Parisian outpost with sweet treats. One thing the century-old Parisian tearoom Angelina has shown is that legendary fashion designer Coco Chanel not only had style and glamor but also boasted great taste in food, pastries in particular. One of the most popular tearooms in Paris, Angelina is famous for having once been frequented by celebrities such as Chanel and writer Marcel Proust. Now Angelina has packed up its French ambience, efficient service, and beautiful, comforting desserts and flown them to Shanghai. At the flagship dine-in and take-out space in Shanghai, everything mimics the original tearoom designed from the beginning of the 20th century, in Paris, the height of Belle Epoque. The paintings on the wall, for example, are exactly the same as the one that depicts the landscape of southern France, the hometown of the owner; and the small tables are intentional imitations of the ones that Coco Chanel once sat at every afternoon for hot chocolate. The famous hot chocolate, known as LAfricain, is a luxurious mixture of four types of cocoa beans imported from Africa, blended in Paris and then shipped to Shanghai. Its sinfully sweet, rich and thick as if putting a bar of melting chocolate directly on the tongue and the fresh whipped cream on the side makes a light, but equally gratifying contrast. It is also sold in glass bottles as takeaway. The signature Mont-Blanc chestnut cake consists of three parts: the pureed chestnut on top, the vanilla cream like stuffing, and the meringue as base. Get all three layers in one scoop, not only for the different textures but also various flavors of sweetness. The dessert has maintained its popularity for a century, even in a country like France, perhaps the worlds most competitive place for desserts. A much overlooked pairing, is the Paris-New York choux pastry and N226 chocolate flavored tea. The choux pastry is a mouthful of airy pecan-flavored whipped cream, while the tea, a blend of black teas from China and Ceylon, cocoa and rose petals, offers a more subtle fragrance of flowers and chocolate. Ordering these two items, featuring a muted sweetness, makes it easier for you to fit into your little black dress. Breakfast, brunch, lunch and light supper are also served at the tearoom, a hub of many cultures and takes in a mix of different styles of French cuisines, according to the management team. The semi-cooked foie gras terrine, is seductive and deceptive. Its generously served at the size and shape of a toast, while the actual brioche toast is baked into a curved slice dipped with fig chutney. The flavor, however, is honest: strong, smooth and sublime. And you dont actually need the toast for crunchiness. This is the season for high teas, with dainty cups of fine china and little pastries that appeal to both visual and physical appetites. But there is one high tea with a difference, and Pauline D. Loh finds out just exactly why it is special. Earl Grey tea and macarons are all very well for the crucial recuperative break in-between intensive bouts of holiday season shopping. And for those who prefer savory to sweet, there is still the selection of classic Chinese snacks called dim sum to satisfy and satiate. High tea is a meal to eat with eye and mouth, an in-between indulgence that should be light enough not to spoil dinner, but sufficiently robust to take the edge off the hunger that strikes hours after lunch. The afternoon tea special at Shang-Xi at the Four Seasons Hotel Pudong has just the right elements. It is a pampering meal, with touches of luxury that make the high tea session a treat in itself. Whole baby abalones are braised and then topped on a shortcrust pastry shell, a sort of Chinese version of the Western vol-au-vent, but classier. Even classier is the dim sum staple shrimp dumpling or hargow, upgraded with the addition of slivers of midnight dark truffles. This is a master touch, and chef Simon Choi, who presides unchallenged at Shang-Xi, has scored a winner again. Sweet prawns and aromatic truffles whats not to love? His masterful craftsmanship is exhibited in yet another pastry a sweet pastry that is shaped to look like a walnut, but which you can put straight into the mouth. It crumbles immediately, and the slightly sweet, nutty morsel is so easy to eat youll probably reach straight for another. My favorite is the dessert that goes by the name yangzhi ganlu, or ambrosia from the gods. The hotel calls it c
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度光伏發(fā)電項(xiàng)目融資租賃合同范本
- 二零二四年牛奶制品生產(chǎn)設(shè)備采購(gòu)合同3篇
- 2025年度大數(shù)據(jù)分析服務(wù)合伙合同范本
- 2025年度跨境電商進(jìn)出口代理服務(wù)外貿(mào)合同書(shū)
- 2025年度云計(jì)算服務(wù)與數(shù)據(jù)存儲(chǔ)合同范本4篇
- 2025年度校園廣告資源整合與營(yíng)銷推廣合同
- 2025年度食品農(nóng)產(chǎn)品安全購(gòu)銷合同及銷售合同范本
- 二零二五年度彩鋼房安全檢查與整改責(zé)任合同2篇
- 2025年度智能交通系統(tǒng)合作反擔(dān)保合同范本
- 《鋼筋焊接及驗(yàn)收規(guī)程》(JGJ18)
- 醫(yī)藥高等數(shù)學(xué)知到智慧樹(shù)章節(jié)測(cè)試課后答案2024年秋浙江中醫(yī)藥大學(xué)
- 2024年濰坊工程職業(yè)學(xué)院?jiǎn)握新殬I(yè)適應(yīng)性測(cè)試題庫(kù)完美版
- GB/T 44823-2024綠色礦山評(píng)價(jià)通則
- 人教版英語(yǔ)高考試卷與參考答案(2024年)
- 《共情的力量》課件
- 2022年中國(guó)電信維護(hù)崗位認(rèn)證動(dòng)力專業(yè)考試題庫(kù)大全-上(單選、多選題)
- 水平二(四年級(jí)第一學(xué)期)體育《小足球(18課時(shí))》大單元教學(xué)計(jì)劃
- 醫(yī)藥高等數(shù)學(xué)智慧樹(shù)知到課后章節(jié)答案2023年下浙江中醫(yī)藥大學(xué)
- 城市道路智慧路燈項(xiàng)目 投標(biāo)方案(技術(shù)標(biāo))
- 水泥采購(gòu)?fù)稑?biāo)方案(技術(shù)標(biāo))
評(píng)論
0/150
提交評(píng)論