




已閱讀5頁,還剩14頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1 電大 C+語言程序設(shè)計(jì)課程的程序分析練習(xí)題 徐孝凱 一 、寫出下列每個(gè)程序運(yùn)行后的輸出結(jié)果 1. #include #include void main() int x=20, y=6, z; char op=+; switch(op) case +: z=x+y; break; case -: z=x-y; break; default: cout操作符 op出錯(cuò),退出運(yùn)行 !;exit(1); cout”z=”zendl; 運(yùn)行結(jié)果: 2. #include #include void main() char* a5=student,worker,cadre,soldier,apen; unsigned int n=strlen(a0); /求字符串 a0的長度 for(int i=1;in) n=strlen(ai); coutnendl; 運(yùn)行結(jié)果: 3. #include int WF(int x, int y) x=x+y; y=x+y; return x+y; void main() coutWF(8,5)endl; 運(yùn)行結(jié)果: 2 4. #include const int N=9; void main() int aN=2,4,6,8,10,12,14,16,18; int s=0; for(int i=0; iN; i+) if(ai%3=0) s+=ai; cout”s=”sendl; 運(yùn)行結(jié)果: 5. #include void main() int* d=new int5; int i,s=0; for(i=0;i5;i+) di=2*i+1; for(i=0;i5;i+) s+=di; cout3*sendl; deleted; 6. #include void SB(char ch) switch(ch) case A: case a: cout優(yōu) ! ; break; case B: case b: cout良 ! ; break; case C: case c: cout通過 ! ; break; default: cout不通過 !;break; void main() SB(A); SB(c); coutendl; 運(yùn)行結(jié)果: 7. #include void main() int a6=36,25,48,14,55,40; int x=a0; 3 for(int i=1;ix) x=ai; cout”x=”xendl; 運(yùn)行結(jié)果: 8. #include void main() int a6=32,53,27,19,12,45; for(int *p=a; pa+6; p+) if(*p%3=0) cout*p ; coutendl; 運(yùn)行結(jié)果: 9. #include int* LG(int m) int* a=new int(m+5); return a; void main() int n1=12; int *b=LG(n1); cout*bendl; delete b; 運(yùn)行結(jié)果: 10. #include #include struct Worker char name15; int age; float pay; ; void main() Worker x; strcpy(, WeiRong); x.age=45; x.pay=3275; x.age x.payendl; 運(yùn)行結(jié)果: 4 11. #include void main() int n=5, sum=0; while(n) sum+=n; n-; cout”sum=”sumendl; 運(yùn)行結(jié)果: 12. #include const int N=6; void main() int aN=76,83,54,62,40,65; int c1, c2; c1=c2=a0; for(int i=1;ic1) c1=ai; else if(aic2) c2=ai; coutc1 c2endl; 運(yùn)行結(jié)果: 13. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a; while(pa+8) cout*p ; p+=3; coutendl; 運(yùn)行 結(jié)果: 14.#include int LF(int x, int y) x=x+y; y=x+y; 5 return x+y; void main() int x=5, y=8; coutLF(1,2) LF(3,4)endl; 運(yùn)行結(jié)果: 15. #include class A int a,b; public: A() a=b=0; A(int aa, int bb) a=aa; b=bb; couta bendl; ; void main() A x,y(3,4); 運(yùn)行結(jié)果: 16. #include void main() int n=4,y=1; while(n-) y*=3; couty=yendl; 運(yùn)行結(jié)果: 17. #include void main() int a8=2,8,10,5,12,7,9,20; int c=0, i=0; while(i10) c+; i+; coutc=cendl; 運(yùn)行結(jié)果: 6 18. #include void main() int a5=3,6,9,12,8; for(int *p=a; p8) cout*p ; 運(yùn)行結(jié)果: 19. #include int LA(int a, int n) int s=0; for(int i=0;in;i+) s+=ai; return s; void main() int a5=5,2,8,6,4; int b=LA(a,5); coutb=bendl; 運(yùn)行結(jié)果: 20. #include struct AB char aa15; int bb; ; void main() AB a4=Apple,25,Peach,40,Pear,36,Tomato,62; for(int i=0;i4;i+) if(ai.bb40) coutai.aa ; coutendl; 運(yùn)行結(jié)果: 21. #include void main() int s1=0; 7 for(int i=1; i=5; i+) s1+=2*i; cout”s1=”s1endl; 輸出結(jié)果: 22. #include void main() int a6=6,9,12,18,15,20; int c=0; for(int i=0; i6; i+) if(ai%2=1) c+; coutc=cendl; 輸出結(jié)果: 23. #include void main() int a34=1,2,7,8,5,6,11,15,9,20,3,4; int m=a00; for(int i=0;i3;i+) for(int j=0;jm) m=aij; coutmendl; 輸出結(jié)果: 24. #include void main() int a=10, b=15, c; c=a+b; int b=a+20; c+=a+b; coutcendl; 輸出結(jié)果: 25. #include void main() 8 int a8=6,19,4,12,20,5,18,25; int *p, s=0; for(p=a; pa+8;p+) if(*p10) s+=*p; coutsendl; 輸出結(jié)果: 26. #include void main() int s=0; for(int i=1;i=8;i+=2) s+=i*i; couts=sendl; 輸出結(jié)果: 27. #include void main() int i=1,s=0; while(s15) s+=i+; couti,sendl; 輸出結(jié)果: 28. #include void main() int a8=36,25,48,14,55,20,47,82; int c1=0, c2=0; for(int i=0; i8; i+) if(ai50) c1+; else c2+; coutc1 c2endl; 輸出結(jié)果: 29. #include int LB(int *a, int n) 9 int p=1; for(int i=0;in;i+) p*=*a; a+; return p; void main() int a5=1,2,3,4,3; coutLB(a,5)endl; 輸出結(jié)果: 30. #include struct Worker char name15; /姓名 int age; /年齡 float pay; /工資 ; void main() Worker x=wangfong,46,1640; Worker y, *p; y=x; p=&x; couty.age+10 pay*2endl; 輸出結(jié)果: 31. #include void main() int n=5, sum=0; while(n) sum+=n*n; n-; coutsum=sumendl; 運(yùn)行結(jié)果: 32. #include const int N=6; void main() int aN=76,83,54,62,40,65; 10 int c1=0; for(int i=0;i=60) c1+; coutc1=c1endl; 運(yùn)行結(jié)果: 33. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a,s=0; while(pa+8) s+=*p; p+=3; coutsendl; 運(yùn)行結(jié)果: 34. #include int a=10, b=15, c; void main() c=a+b; int b=a+20; c+=a+b; coutcendl; 輸出結(jié)果: 35. #include void FF(int a, int n) int i,x; for(i=0; in/2; i+) x=ai; ai=an-1-i; an-1-i=x; void main() int a8=6,19,4,12,20,5,18,25; FF(a,8); couta0,a1b) a=b; if(ac) a=c; return a; 函數(shù)功能: 2. double WA(double a, int n) double s=0; for(int i=0;in;i+) s+=ai; return s/n; 函數(shù)功能: 3. double SF(double x, int n) /n為大于等于 0的整數(shù) double p=1,s=1; for(int i=1;i=n;i+) p*=x; s+=p/(i+1); return s; 函數(shù)功能: 4. double FI(double n) /n為大于等于 1的整數(shù) double x,y=0; for(int i=0; ix; y+=x; return y; 函數(shù)功能: 5. int WG(int a, int b) if(a0 & b0) return 1; else if(a0 & bnext; return n; 函數(shù)功能: 7. int SA(int a, int b) if(ab) return 1; else if(a=b) return 0; else return -1; 函數(shù) 功能: 8. int LK(int a, int n) float s=0; int i; for(i=0;in;i+) s+=ai; s/=n; int m=0; for(i=0;i=s) m+; return m; 函數(shù)功能: 9. int WD(int a, int n) int m=a0; for(int i=1;im) m=ai; return m; 函數(shù)功能: 10. bool WB(int a, int n, int x) for(int i=0;in;i+) if(ai=x) return true; return false; 14 函數(shù)功能: 11. int LJ(int a, int n) int k=0; for(int i=1;iak) k=i; return ak; 函數(shù)功能: 12. 假定結(jié)構(gòu)類型 DNode中的 data域?yàn)榻Y(jié)點(diǎn)值域, next域?yàn)榻Y(jié)點(diǎn)指針域。 void QB(DNode *f) /f指向單鏈表的表頭結(jié)點(diǎn) if(f=NULL) return; while(f!=NULL) coutdatanext; 函數(shù)功能: 13 int WC(int a, int n, int k) int c=0; for(int i=0;i=k) c+; return c; 函數(shù)功能: 14. bool SG(int x) /x為大于等于 2的整數(shù) int a=int(sqrt(x); /sqrt(x)為求 x的平方根 int i=2; while(i=a) if(x%i=0) break; i+; if(i=a) return true; else return false; 15 函數(shù)功能: 15. 假定結(jié)構(gòu)類型 Worker中的 name域表示姓名, age域表示年齡, pay域表示工資。 void QA(Worker a, int n) for(int i=0; ai.ageai.pay; 函數(shù)功能: 16. double FI(int n) /n為大于等于 1的整數(shù) double x,y=0; do cinx; y+=x*x; while(-n); return y; 函數(shù)功能: 17. bool WE(int a, int b, int n) for(int i=0;in;i+) if(ai!=bi) break; if(i=n) return true; return false; 函數(shù)功能: 18. int LK(int a, int n) double s=0; int i,m=0; for(i=0;in;i+) s+=ai; s=s/n; for(i=0;i=s) m+; return m; 函數(shù)功能: 16 19. double FI(int n) /n為大于等于 1的整數(shù) double x,y=0; do cinx; y+=x; while(-n); return y; 函數(shù)功能: 20. bool WE(int a, int b, int n) for(int i=0;in;i+) if(ai!=bi) break; if(i=n) return true; return false; 函數(shù)功能: 21. int LK(int a, int n) double s=0; int i,m=0; for(i=0;in;i+) s+=ai; s=s/n; for(i=0;i=s) m+; return m; 函數(shù)功能: 二 、 寫 出下列每個(gè)函數(shù)的功能( 參考答案 ) 評分標(biāo)準(zhǔn):每題與參考答案的敘述含義相同者得 8分,否則酌情給分。 1. 求出 a,b,c三個(gè)數(shù)中的最小值并返回。 2. 求出數(shù)組 a中 n個(gè)元素的平均值并返回。 3. 計(jì)算出表達(dá)式1.3221 nnxxx 的值并返回。 4. 求出并返回從鍵盤上輸入的 n個(gè)實(shí)數(shù)之和。 5. 若 a和 b都大于 0則返回 1,若 a和 b都小于 0則返回 -1,其他任何情況則返回 0。 6. 求出并返回 f單鏈表的長度(即結(jié)點(diǎn)個(gè)數(shù))。 7. 比較兩個(gè)整數(shù) a和 b的大小,若 ab則返回 1,若 a=b則返回 0,若 ab則返回 -1。 8. 求出數(shù)組 a的 n個(gè)元素中大于等于平均值的元素個(gè)數(shù)并返回。 9. 從數(shù)組 a的 n個(gè)元素中求出最大值并返回。 10.從數(shù)組 a中順序查找值為 x的元素,若查找成功則返回真,否則返回假。 11.求出數(shù)組 a中 n個(gè)元素的最大值并返回。 17 12.遍歷輸出 f單鏈表中的所有結(jié)點(diǎn)的值。 13. 統(tǒng)計(jì)出數(shù)組 a的 n個(gè)元素中大于等于參數(shù) k的值的元素個(gè)數(shù)并返回。 14. 判斷 x是否為一個(gè)素?cái)?shù)(或質(zhì)數(shù)),若是則返回真,否則返回假。 15. 從鍵盤上輸入 n個(gè) Worker結(jié)構(gòu)類型的記錄依次保存到一維數(shù)組 a的對應(yīng)元素中。 16.求出從鍵盤上輸入的 n個(gè)整數(shù)的平方和并返回。 17. 判斷具有 n個(gè)元素的兩個(gè)數(shù)組 a和 b中對應(yīng)元素值是否全部相等,若是則返回真,否則返回假。 18.統(tǒng)計(jì)出數(shù)組 an中大于等于其平均值的元素個(gè)數(shù)并作為函數(shù)值返回。 19.求出從鍵盤上輸入的 n個(gè)整數(shù)的和并返回。 20. 判斷具有 n個(gè)元素的兩個(gè)數(shù)組 a和 b中對應(yīng)元素值是否全部相等,若是則返回真,否則返回假。 21.統(tǒng)計(jì)出數(shù)組 an中大于等于其平均值的元素個(gè)數(shù)并作為函數(shù)值返回。 18 請您刪除一下內(nèi)容, O( _ )O謝謝! 2015年中央電大期末復(fù)習(xí)考 試小抄大全,電大期末考試必備小抄,電大考試必過小抄 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 f
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 醫(yī)藥市場營銷的倫理邊界與監(jiān)管
- 醫(yī)療信息化對教育領(lǐng)域的啟示
- Axure RP 互聯(lián)網(wǎng)產(chǎn)品原型設(shè)計(jì)課件 第6章 使用母版和動態(tài)面板
- 創(chuàng)新型智慧藥房系統(tǒng)在醫(yī)療園區(qū)的推廣與應(yīng)用
- 傳媒公司商家合同范例
- 醫(yī)療大數(shù)據(jù)驅(qū)動的公共衛(wèi)生健康監(jiān)測
- 醫(yī)療教育中的溝通藝術(shù)培養(yǎng)卓越醫(yī)者
- 買房公示合同范例
- 借款附帶質(zhì)押合同范例
- 保潔消毒合同范例
- 中醫(yī)內(nèi)科學(xué)-痹證
- 幼兒園中班社會《猜猜這是誰的包》課件
- 網(wǎng)絡(luò)安全宣傳周網(wǎng)絡(luò)安全知識手冊學(xué)習(xí)課件
- TTJSFB 002-2024 綠色融資租賃項(xiàng)目評價(jià)指南
- 2024年公文寫作基礎(chǔ)知識競賽試題庫及答案(共220題)
- 實(shí)驗(yàn):驗(yàn)證動量守恒定律 說課課件-2024-2025學(xué)年高二上學(xué)期物理人教版(2019)選擇性必修第一冊
- 管道大開挖穿越公路施工方案
- 省級一網(wǎng)統(tǒng)管網(wǎng)格化社會治理指揮手冊(含事項(xiàng)清單)
- vte的預(yù)防與管理完整版
- 污水處理設(shè)備運(yùn)行記錄臺賬
- 2024年合肥市蜀山區(qū)中考二模英語試題含答案
評論
0/150
提交評論