ImageVerifierCode 换一换
格式:DOCX , 页数:40 ,大小:26KB ,
资源ID:8353408      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8353408.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C++primerplus中文版编程练习答案.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C++primerplus中文版编程练习答案.docx

1、C+primerplus中文版编程练习答案n”;endl; return 0;double C2F(double t)return *t+32;endl; return 0;double convert(double t)return 63240*t;n; return 0;style(miles per gallon):endl; coutEuro_style L/100Km = *Euro_styleUS_style;coutConverts to European style(miles per gallon):endl; coutUS_style mpg = *US_styleL/10

2、0Kmn; return 0;style(miles per gallon):19Converts to European style(miles per gallon): 19 mpg = 100KmPress any key to continue第四章 复合类型n;return 0;randendlsnacki.weightendlsnacki.caloryendlendl;return 0;rand=A;eight=;snack0.calory=200; snack1.brand=B; snack1.weight=; snack1.calory=400; snack2.brand=C;

3、 snack2.weight=; snack2.calory=500;for(int i=0;i3;i+)cout brand: snacki.brand endl; cout weight: snacki.weight endl;cout calorie: snacki.calory endlendl;delete snack; return 0;et(); car* ps=new carnum;for(int i=0;inum;+i)coutCar #i+1:n; coutPlease enter the make: ; getline(cin,psi.name); coutpsi.yea

4、r).get();coutHere is your collection:n; for(int i=0;inum;+i) coutpsi.year psi.nameendl; delete ps;return 0;#include #include using namespace std; struct carstring maker; int year;int main()int number;cout number;car* a = new carnumber;for (int i = 0; i number; i+)cout Car # i+1 : endl; cout Please e

5、nter the maker: ; ();getline(cin,ai.maker);cout ai.year;cout Here is your collection: endl; for (int i = 0; i number; i+)cout ai.year ai.maker endl; delete a;return 0;#include using namespace std; struct carchar maker20; int year;int main()int number;cout number;car* a = new carnumber;for (int i = 0

6、; i number; i+)cout Car # i+1 : endl; cout Please enter the maker: ; ();(ai.maker, 20);cout ai.year;cout Here is your collection: endl; for (int i = 0; i number; i+)cout ai.year ai.maker endl; delete a;return 0;n; return 0;n;return 0;和 的区别是:word != done,因为当 word = done 一样时,返回值为 1,不一样时 才是返回 0.;for(in

7、t k=0;k=i;+k) cout*; coutendl;return 0;第六章 分支语句和逻辑运算符n; break;case p:coutA maple is a pianist.n; break;case t:coutA maple is a tree.n; break;case g:return 0;coutA maple is a game.n;#include using namespace std; void show();int main()show();char choice;while (cin choice)switch(choice)case c : cout It

8、s a carnivore.n; break;case p : cout Its a pianist.n; break;case t : cout A maple is a tree.n; break;case g : cout Its a game.n; break;default : cout Please enter a c, p, t, or g:;return 0;void show()cout Please enter one of the following choices: n c) carnivore p) pianistnt) tree g) gamen;display b

9、y name b. display by titlenc. display by bopname d. diplay by preferencenq. quitn; char ch;bop member5=Wimp Macho,English 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;coutch&ch!=q)switch(ch)case a:for

10、(int i=0;i5;i+) coutmemberi.fullnameendl; break;case b:for(int i=0;i5;i+) coutmemberi.titleendl; break;case c:for(int i=0;i5;i+) coutmemberi.bopnameendl; break;case d:for(int i=0;i5;i+)if(memberi.preference=0) coutmemberi.fullnameendl; else if(memberi.preference=1) coutmemberi.titleendl; else if(mem

11、beri.preference=2) coutmemberi.bopnameendl;break;coutNext choice: ;coutBye!n; return 0;#include using namespace std; const int strsize = 30; struct bopchar fullnamestrsize; char titlestrsize; char bopnamestrsize; int preference;void show(); int main()bop A5 =Wimp Macho, Teacher, HAHA, 0,Raki Rhodes,

12、 Junior Programmer, LIAR, 1,Celia, engineer, MIPS, 2,Hoppy Hipman, Analyst Trainee, WAHU, 1,Pat Hand, Student, LOOPY, 2;cout Benevolent Order of Programmers Reportn; show();cout choice;while (choice != q)switch(choice)case a : cout A0.fullname endl A1.fullname endl A2.fullname endl A3.fullname endl

13、A4.fullname endl; break;case b : cout A0.title endl A1.title endl A2.title endl A3.title endl A4.title endl; break;case c : cout A0.bopname endl A1.bopname endl A2.bopname endl A3.bopname endl A4.bopname endl; break;case d : cout A0.fullname endl A1.title endl A2.bopname endl A3.title endl A4.bopnam

14、e endl; break;default : cout Thats not the proper choice.n;cout choice;cout Bye!n; return 0;void show()cout a. display by name b. display by titlen c. display by bopname d. display by preferencen q. quitn;ame); cout请输入第i+1psi.money;();coutGrand Patrons:n; for(int i=0;i10000)coutpsi.namenpsi.moneyend

15、l;+temp;if(temp=0) coutnonen;coutPatrons:n; for(int i=0;inum;+i) if(psi.money=10000)coutpsi.namenpsi.moneyendl;+temp;if(temp=0) coutnonen;delete ps; return 0;#include #include using namespace std; struct charitystring name; double money;int main()int number; int count = 0;cout number;charity *pt = n

16、ew charitynumber; for (int i = 0; i number; i+)cout Please enter your name: ; ();getline(cin, pti.name);cout pti.money;if(pti.money 10000) count+;if(count = 0)cout 10000); elsecout Grand Patronn; for(int i = 0; i 10000)cout pti.name pti.money endl;cout endl;if(10 - count = 0)cout None(money 10000);

17、elsecout Patronn;for(int i = 0; i number; i+)if(pti.money 10000)cout pti.name pti.money ch; while()+sum; inFilech;if()coutEnd of file reached.n; else if()coutInput terminated by data mismatch.n; elsecoutInput terminated for unkonwn reason.n;cout总共有sum个字符在这个文件中。endl; return 0;#include #include #inclu

18、de using namespace std; const int Size = 20; int main()char filenameSize; ifstream infile;cout Enter name of data file: ; (filename, Size); (filename);if (!()cout Could not open the file filename endl; cout a;while ()+count; infile a;if ()cout End of file reached.n; else if ()cout Input terminated b

19、y data mismatch.n; elsecout Input terminated for unknown reason.n; if (count = 0)cout No data processed.n; elsecout The text contains count character(s) num; ();member *pd=new membernum; for(int i=0;ipdi.donation; ();coutGrand Patrons:n; for(int i=0;i=10000)coutpdi.namenpdi.donationendl; count1+;if(

20、count1=0) coutnonen; coutPatrons:n; for(int i=0;inum;i+) if(pdi.donation10000)coutpdi.namenpdi.donationendl; count2+;if(count2=0) coutnonen;delete pd; return 0;#include #include #include #include using namespace std; struct charitystring name; double money;int main()string filename; ifstream infile;

21、cout Enter name of data file: ; getline(cin, filename); (filename);if (!()cout Could not open the file filename endl; cout number;charity *pt = new charitynumber; for (int i = 0; i pti.money; if(pti.money 10000)count+;if(count = 0)cout 10000); elsecout Grand Patron:n; for(int i = 0; i 10000)cout pti.name pti.money endl;if(10 - count = 0)cout None(money 10000); elsecout Patron:n;for(int i = 0; i number; i+)if(pti.money 10000)cout pti.name pti.money endl;delete pt; return 0;第 7 章 函数C+的编程模块n;return 0;int input(double score, int limit)double a; int i;for

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1