




已閱讀5頁,還剩7頁未讀, 繼續免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
電大 C+語言程序設計期末復習題 及答案小抄資料 一、單項選擇題 1、 面向對象程序設計數據與 _放在一起,作為一個相互依存、不可分割的整體來處理。 A、對數據的操作 B、信息 C、數據隱藏 D、數據抽象 2、 已知: int a=1,b=2,c=3,d=4,則表達式 ab?a: cd?c: d 的值為 _。 A、 1 B、 2 C、 3 D、 4 3、下列 while 循環的次數是 _。 while( int i=0 ) i- -; A、 0 B、 1 C、 5 D、無限 4、以下程序的輸出結果是 _。 #include fuc( char* s) char* p=s; while( *p) p+; return (p-s); main() coutfuc(ABCDEF); A、 3 B、 6 C、 8 D、 0 5、 _的功能是對對象進行初始化。 A、析構函數 B、數據成員 C、構造函數 D、靜態成員函數 6、下列引用的定義中, _是錯誤的。 A、 int i; B、 int i; C、 float i; D、 char d; int& j=i; int &j; float& j=i; j=i; char &k=d; 7、若類 A 和類 B 的定義如下: class A int i,j; public: void get(); /. ; class B: public A int k; public: make(); /. ; void B:make() k=i*j; 則上述定義中, _是非法的表達式。 A、 void get(); B、 int k; C、 void make(); D、 k=i*j; 8、以下程序段 _。 int x = -1; do x = x*x; while( !x ); A、是死循環 B、循環執行 2 次 C、循環執行 1 次 D、有語法錯誤 9、對定義重載函數的下列要求中, _是錯誤的。 A、要求參數的個數不同 B、要求參數中至少有一個類型不同 C、要求參數個數相同時,參數類型不同 D、要求函數的返回值不同 10、一個 _允許用戶為類定義一種模式,使得類中的某些數據成員及某些成員函數的返回值能取任意類型。 A、函數模板 B、模板函數 C、類模板 D、模板類 ( Key:1-5:AAABC 6-10:BDCDC) 二、填空題 1、在 C+類中可以包含 、 和 三種具有不同訪問控制權的成員。( Key:公有或 public,保護或 protected,私有或 private) 2、以下程序的執行結果是 _。 #include void func( int ); void func( double ); void main( ) double a=88.18; func(a); int b=97; func(b); void func( int x ) coutxendl; void func( double x ) coutx, ; (Key: 88.18, 97) 3、類中的數據和成員函數默認訪問類型為 _。 (Key:私有或 private) 4、以下程序的執行結果是 _。 #include using namespace std; f(int b,int n) int i,r=1; for( i=0;i=n;i+ ) r=r*bi; return r; int _tmain() int x,a = 2,3,4,5,6,7,8,9; x=f(a,3); coutx=xendl; return 0; (Key: x=120) 5、在類內部定義的 _數據不能被不屬于該類的函數來存取,定義為 _的數據則可以在類外部進行存取。 (Key:private 或 私有 或 protected 或 保護; public 或 公有 ) 6、下列程序輸出的結果是 _。 #include using namespace std; void sub( char a,char b ) char c=a; a=b; b=c; void sub( char* a,char b ) char c=*a; *a=b; b=c; void sub( char* a,char* b ) char c=*a; *a=*b; *b=c; int _tmain() char a=A,b=B; sub(&a,&b); coutabendl; return 0; (Key: BA) 7、下列程序輸出的結果是 _。 #include using namespace std; void Exchange( int* pFirst,int* pLast ) if( pFirstpLast ) int Change = *pFirst; *pFirst = *pLast; *pLast = Change; Exchange(+pFirst,-pLast); void Print( int Integer,int HowMany) for( int Index=0; IndexHowMany; Index+ ) coutIntegerIndex ; coutendl; int _tmain() int Integer = 1,2,3,4; Exchange(&Integer0,&Integer3); Print(Integer,4); return 0; (Key: 4 3 2 1) 8、下列程序輸出的結果是 _。 #include using namespace std; int _tmain() int nInteger = 5, &rInteger = nInteger; rInteger = nInteger+1; coutnInteger,rIntegerendl; return 0; (Key: 6,6) 9、 _是一種特殊的成員函數 ,它主要用來為對象分配內存空間 ,對類的數據成員進行初始化并進行對 象的其他內部管理操作。 (構造函數 ) 10、下列程序輸出的結果是 _。 #include using namespace std; int _tmain() int x=2,y=3,z=4; cout( xy ) & ( !z ) | (x*y) )endl; return 0; (Key:1) 三、程序分析:給出程序運行后的輸出結果 (每小題 5 分 ,共 20 分 ) 1、 #include using namespace std; int _tmain() int x=1,y=2,z=3; x+=y+=z; cout(xy?y:x),; cout(xy?x+:y+),; coutyendl; return 0; Key: 6,5,6 2、 #include using namespace std; void func( int b ); void main() int a = 5,6,7,8 ,i; func(a); for( i=0; i4; i+ ) coutai ; void func( int b ) int j; for( j=0; j4; j+ ) bj = 2*j; Key: 0 2 4 6 3、 #include using namespace std; class CSample int i; public: CSample(void); CSample(void); CSample(int val); void Print(void); ; CSample:CSample(void) coutConstructor1endl; i=0; CSample:CSample(int val) coutConstructor2endl; i=val; void CSample:Print(void) couti=iendl; CSample:CSample(void) coutDestructorendl; int _tmain() CSample a,b(10); a.Print(); b.Print(); return 0; Key: Constructor1 Constructor2 i=0 i=10 Destructor Destructor 4、 #include using namespace std; class CData protected: int nInteger; public: CData( int Integer ); CData( void ); void Print(void); ; CData:CData( int Integer ) : nInteger(Integer) coutConstructing a dataendl; CData:CData( void ) coutDestructing a dataendl; void CData:Print(void) coutThe data is nIntegerendl; class CNumber : public CData protected: double fNumber; public: CNumber(int Integer,double Number); CNumber(void); void Print(void); ; CNumber:CNumber( int Integer,double Number ) : CData( Integer ) , fNumber(Number) coutConstructing a numberendl; CNumber:CNumber( void ) coutDestructing a numberendl; void CNumber:Print(void) CData:Print(); coutThe number is fNumberendl; int _tmain() CNumber Number(1,3.8); Number.Print(); return 0; Key: Constructing a data Constructing a number The data is 1 The number is 3.8 Destructing a number Destructing a data 四、根據要求完成程序 1、完成以下程序,求 1!+2!+3!+4!+5!+6!+7!+8!+9!+10!之和。 #include using namespace std; int _tmain() long Term=_ ,Sum=_; for( int Index=1; Index=_; Index+) Term *=_; Sum +=_; coutSum of factorial from 1 to 10 is ; coutSumendl; return 0; Key:1 0 10 Index Term 2、完成下面程序,計算三角形和正方形的面積。設三角形和正方形的寬為 fWidth,高為 fHeight,則三角形的面積為 fWidth*fHeigth/2。 #include using namespace std; class CShape public: CSquare:CSquare(double Width,double Height) :_ double CSquare:Area(void) _; int _tmain() CTriangle Triangle(16,8); coutThe area of triangle is Triangle.Area()endl; CSquare Square(13,8); coutThe area of square is Square.Area()endl; return 0; Key: fWidth(Width) CShape(Width,Height) return fWidth*fHeight/2 CShape(Width,Height) return fWidth*fHeight 五、用面向對象方法設計一個階乘類 CFactorial,在 CFactorial 類的構造函數 CFactorial(long Integer)中 ,將 Integer 的值賦給 nInteger;在主函數 int _tmain(),鍵盤輸入任一整數 Integer,以 Integer 的值為實際參數構造一個階乘對象 Factorial,調用對象 Factorial 的相應成員函數輸出 nInteger 的階乘值fFactorial。完成以下函數的代碼設計: ( 1)、設計構造函數 CFactorial(long Integer),求出 nInteger 的階乘值 fFactorial。若 nInteger 沒有階乘值,則 fFactorial 賦值為 0。 ( 2)、設計 CFactorial 類的成員函數 void Print(void),輸出 nInteger 的階乘值 fFactorial。若 nInteger沒有階乘,則輸出 nInteger 沒有階乘的信息。 #include using namespace std; class CFactorial public: CFactorial(long Integer); protected: long nInteger; float fFactorial; public: void Print(void); ; CFactorial:CFactorial(long Integer) : nInteger(Integer) /作答處 void CFactorial:Print(void) /作答處 int _tmain() long Integer; coutInteger; CFactorial Factorial(Integer); Factorial.Print(); return 0; Key: 解:參考程序: #include using namespace std; class CFactorial public: CFactorial(long Integer); protected: long nInteger; float fFactorial; public: void Print(void); ; CFactorial:CFactorial(long Integer) : nInteger(Integer) if( nInteger1 ) /1 分 fFactorial*=Integer; /1 分 Integer-; /1 分 void CFactorial:Print(void) if( fFactorial ) /0.5 分 coutThe factorial of nInteger is fFactorialendl; /1 分 else /0.5 分 coutThere is not any factorial for nIntegerendl; /1 分 int _tmain() long Integer; coutInteger; CFactorial Factorial(Integer); Factorial.Print(); return 0; 請您刪除一下內容, O( _ )O 謝謝! 2015 年中央電大期末復習考試小抄大全,電大期末考試必備小抄,電大考試必過小抄 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 ya
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 紙漿篩選與凈化設備的運行與維護考核試卷
- 海洋油氣開采中的海洋生物多樣性保護考核試卷
- 紙板容器生命周期分析考核試卷
- 終端設備在水下通信技術考核試卷
- 林業與地方特色農產品的區域品牌營銷考核試卷
- 纖維素纖維在聲學材料中的應用考核試卷
- 種子種苗在氣候變化適應中的作用考核試卷
- 玻璃纖維增強型塑料水處理設備的制備考核試卷
- 畜禽智能養殖環境監測與調控系統考核試卷
- 南京旅游職業學院《交通運輸工程前沿講座》2023-2024學年第二學期期末試卷
- 胸腔穿刺術課件
- 簡易呼吸器操作流程及考核評分表
- 人行天橋施工組織設計方案
- 工程設計管理規定
- 學習解讀2023年《堤防運行管理辦法》《水閘運行管理辦法》課件
- 新課標背景下課堂教學中的跨學科教學探究 論文
- 安徽筑格橋梁構件有限公司高端工程金屬橡膠產品(公路橋梁伸縮裝置、板式橡膠支座、盆式橡膠支座、QZ球形支座、橡膠止水帶等)項目 環境影響報告書
- 危險廢物填埋場
- 視線設計、座位排布分析
- YY 0780-2018電針治療儀
- RB/T 039-2020檢測實驗室儀器設備計量溯源結果確認指南
評論
0/150
提交評論