C++Primer Plus第六章编程练习.doc
《C++Primer Plus第六章编程练习.doc》由会员分享,可在线阅读,更多相关《C++Primer Plus第六章编程练习.doc(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、第六章编程练习1、#include #include int main() using namespace std; char ch; cin.get(ch); while(ch!=) if(isdigit(ch) cin.get(ch); else if(islower(ch) ch=toupper(ch); else ch=tolower(ch); coutch; cin.get(ch); system(pause); return 0; 2、#include int main() using namespace std; double sum=0; double average=0; d
2、ouble num10; int i=0,total=0; double tmp; while(cintmp&i10) numi=tmp; sum+=numi; +i; if(i!=0) average=sum/i; for(int j=0;javerage) +total; cout这些数字的平均值为averageendl; cout并且共有total个数字大于平均值。n; system(pause); return 0; 3、#include int main() using namespace std; coutPlease enter one of the following choi
3、ces:n c)carnivore p)pianistn t)tree g)gamenfn; coutch; while(ch!=c&ch!=p&ch!=t&ch!=g) coutch; switch(ch) case c: coutA maple is a tree.n; break; case p: coutA maple is a pianist.n; break; case t: coutA maple is a tree.n; break; case g: coutA maple is a game.n; system(pause); return 0; 4、#include con
4、st int strsize=20;struct bop char fullnamestrsize; char titlestrsize; char bopnamestrsize; int preference;int main() std:coutBenevolent Order of Programmers Reportn a. display by name b. display by titlen c. display by bopname d. diplay by preferencen q. quit; char ch; bop member5=Wimp Macho,English
5、 Teacher,DEMON,0, Raki Rhodes,Junior Programmer,BOOM,1, Celia Laiter,Super Star,MIPS,2, Hoppy Hipman,Analyst Trainee,WATEE,1, Pat Hand,Police,LOOPY,2; std:coutch&ch!=q) switch(ch) case a: for(int i=0;i5;i+) std:coutmemberi.fullnamestd:endl; break; case b: for(int i=0;i5;i+) std:coutmemberi.titlestd:
6、endl; break; case c: for(int i=0;i5;i+) std:coutmemberi.bopnamestd:endl; break; case d: for(int i=0;i5;i+) if(memberi.preference=0) std:coutmemberi.fullnamestd:endl; else if(memberi.preference=1) std:coutmemberi.titlestd:endl; else if(memberi.preference=2) std:coutmemberi.bopnamestd:endl; std:coutNe
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C+Primer Plus第六章编程练习 Primer Plus 第六 编程 练习
限制150内