ImageVerifierCode 换一换
格式:DOC , 页数:19 ,大小:85KB ,
资源ID:2492927      下载积分:8 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

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

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

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(c++primerplus(第六版)课后编程练习答案.doc)为本站上传会员【精****】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

c++primerplus(第六版)课后编程练习答案.doc

1、第二章:开始学习C++ //ex2.1--display your name and address #include int main(void) { using namespace std; cout<<"My name is liao chunguang and I live in hunan chenzhou.\n”; } //ex2.2--convert the furlong units to yard uints-把浪单位换位码单位 #include double fur2yd(double); int mai

2、n() { using namespace std; cout<<"enter the distance measured by furlong units:"; double fur; cin>>fur; cout<<"convert the furlong to yard"<

3、} //ex2.3-每个函数都被调用两次 #include void mice(); void see(); using namespace std; int main() { mice(); mice(); see(); see(); return 0; } void mice() { cout<<"three blind mice"<

4、am> int main() { using namespace std; cout<<"Enter your age:"; int age; cin>>age; int month; month=age*12; cout< double C2F(double); int main()

5、{ using namespace std; cout<<"please enter a Celsius value:"; double C; cin>>C; double F; F=C2F(C); cout<

6、把光年转换为天文单位 #include double convert(double);//函数原型 int main() { using namespace std; cout<<"Enter the number of light years:"; double light_years; cin>>light_years; double astro_units; astro_units=convert(light_years); cout<

7、ical units."< void show(); main() { using namespace std; show(); return 0; } void show() { using namespace std; int h,m; cout<<"enter the number of hours

8、"; cin>>h; cout<<"enter the number of minutes:"; cin>>m; cout<<"Time:"< const int inch_per_feet=12;// const常量--1feet=12inches--1英尺=12英寸 int main() { using namespace std; cout<<"please enter your hei

9、ght in inches:___\b\b\b";// \b表示为退格字符 int ht_inch; cin>>ht_inch; int ht_feet=ht_inch/inch_per_feet;//取商 int rm_inch=ht_inch%inch_per_feet;//取余 cout<<"your height is "<

10、 const int inch_per_feet=12; const double meter_per_inch=0.0254; const double pound_per_kilogram=2.2; int main() { using namespace std; cout<<"Please enter your height:"<>ht_feet; cout<<"Second,ente

11、r your height of inch part(输入你身高的英寸部分):_\b"; int ht_inch; cin>>ht_inch; cout<<"Now,please enter your weight in pound:___\b\b\b"; double wt_pound; cin>>wt_pound; int inch; inch=ht_feet*inch_per_feet+ht_inch; double ht_meter; ht_meter=inch*meter_per_inch; double wt_kilogram; wt_k

12、ilogram=wt_pound/pound_per_kilogram; cout<

13、x(体重指数) is "< const int minutes_per_degree=60; const int seconds_per_minute=60; int main() { using namespace std; cout<<"Enter a latitude in degrees,minutes,and seconds:\n"; cout<<"First,enter the degrees:"; int degre

14、e; cin>>degree; cout<<"Next,enter the minutes of arc:"; int minute; cin>>minute; cout<<"Fianlly,enter the seconds of arc:"; int second; cin>>second; double show_in_degree; show_in_degree=(double)degree+(double)minute/minutes_per_degree+(double)second/minutes_per_degree/seconds_per_

15、minute; cout< const int hours_per_day=24; const int minutes_per_hour=60; const int seconds_per_minute=60; int main() { using namespace std; cout<<"En

16、ter the number of seconds:"; long seconds; cin>>seconds; int Day,Hour,Minute,Second; Day=seconds/seconds_per_minute/minutes_per_hour/hours_per_day; Hour=seconds/seconds_per_minute/minutes_per_hour%hours_per_day; Minute=seconds/seconds_per_minute%minutes_per_hour; Second=seconds%seconds

17、per_minute; cout< int main() { using namespace std; cout<<"Enter the world population:"; long long world_population; cin>>world_population; c

18、out<<"Enter the population of the US:"; long long US_population; cin>>US_population; double percentage; percentage=(double)US_population/world_population*100; cout<<"The population of the US is "<

19、100Km) #include int main() {  using namespace std;  cout<<"Enter the miles of distance you have driven:";  double m_distance;  cin>>m_distance;  cout<<"Enter the gallons of gasoline you have used:";  double m_gasoline;  cin>>m_gasoline;  cout<<"Your car can run "<

20、asoline<<" miles per gallon\n";  cout<<"Computing by European style:\n";  cout<<"Enter the distance in kilometers:";  double k_distance;  cin>>k_distance;  cout<<"Enter the petrol in liters:";  double k_gasoline;  cin>>k_gasoline;  cout<<"In European style:"<<"your can used "<<100*k_gasoline

21、/k_distance<<" liters of petrol per 100 kilometers\n";  return 0; } //ex3.7 automobile gasoline consumption-耗油量--欧洲风格(L/100Km)转换成美国风格(mpg) #include int main() { using namespace std; cout<<"Enter the automobile gasoline consumption figure in\n" <<"European style(liters per

22、 100 kilometers):"; double Euro_style; cin>>Euro_style; cout<<"Converts to U.S. style(miles per gallon):"<

23、out 12.4 L/100Km, and 27 mpg is about 8.7 L/100Km. Enter the automobile gasoline consumption figure in European style(liters per 100 kilometers):12.4 Converts to U.S. style(miles per gallon): 12.4 L/100Km = 19.4187 mpg Press any key to continue // ex3.7 automobile gasoline consumption-耗油量--美国

24、风格(mpg)转换成欧洲风格(L/100Km) #include int main() { using namespace std; cout<<"Enter the automobile gasoline consumption figure in\n" <<"U.S. style(miles per gallon):"; double US_style; cin>>US_style; cout<<"Converts to European style(miles per gallon):"<

25、<" mpg = "<< 62.14*3.875/US_style<<"L/100Km\n"; return 0; } // Enter the automobile gasoline consumption figure in U.S. style(miles per gallon):19 Converts to European style(miles per gallon): 19 mpg = 12.6733L/100Km Press any key to continue 第四章 复合类型 //ex4.1 display the information of s

26、tudent #include const int Asize=20; using namespace std; struct student//定义结构描述 { char firstname[Asize]; char lastname[Asize]; char grade; int age; }; void display(student);//函数原型放在结构描述后 int main() { cout<<"what is your first name?"<

27、象) cin.getline(lcg.firstname,Asize); cout<<"what is your last name?"<>lcg.grade; cout<<"what is your age?"<>lcg.age; display(lcg); return 0; } void display(student name) {

28、 cout<<"Name: "< #include int main() { using namespace std; string name,dessert; cout<

29、<"Enter your name: \n"; getline(cin,name); cout<<"Enter your favorite dessert: \n"; getline(cin,dessert); cout<<"I have some delicious "<

30、 {_Chg = true; _I.rdbuf()->sbumpc();//修改后的 break; } ex4.3 输入其名和姓,并组合显示 #include #include const int Asize=20; int main() { using namespace std; char fname[Asize]; char lname[Asize]; char fullname[2*Asize+1]; cout<<"Enter y

31、our first name:";//输入名字,存储在fname[]数组中 cin.getline(fname,Asize); cout<<"Enter your last name:";//输入姓,存储在lname[]数组中 cin.getline(lname,Asize); strncpy(fullname,lname,Asize);//把姓lname复制到fullname空数组中 strcat(fullname,", ");//把“, ”附加到上述fullname尾部 strncat(fullname,fname,Asize);//把fname名字附加到上述ful

32、lname尾部 fullname[2*Asize]='\0';//为防止字符型数组溢出,在数组结尾添加结束符 cout<<"Here's the information in a single string:"< #include int main() { using namespace std; string fname,lname,attach,fullname; c

33、out<<"Enter your first name:"; getline(cin,fname);//note:将一行输入读取到string类对象中使用的是getline(cin,str) //它没有使用句点表示法,所以不是类方法 cout<<"Enter your last name:"; getline(cin,lname); attach=", "; fullname=lname+attach+fname; cout<<"Here's the information in a single string:"<

34、name< const int Asize=20; struct CandyBar { char brand[Asize]; double weight; int calory; }; int main() { using namespace std; CandyBar snack={"Mocha Munch",2.3,350}; cout<<"Here's

35、the information of snack:\n"; cout<<"brand:"< const int Asize=20; struct CandyBar { char brand[Asize]; double weight; int calory; };

36、 int main() { using namespace std; CandyBar snack[3]={ {"Mocha Munch",2.3,350}, {"XuFuJi",1.1,300}, {"Alps",0.4,100} }; for(int i=0;i<3;i++)//利用for循环来显示snack变量的内容 { cout<

37、 //ex4.7 pizza披萨饼 #include #include const int Size=20; struct pizza//声明结构 { char company[Size]; double diameter; double weight; }; int main() { using namespace std; pizza pie;//创建一个名为pie的结构变量 cout<<"What's the name of pizza company:"; cin.getline(pany,Siz

38、e); cout<<"What's the diameter of pizza:"; cin>>pie.diameter; cout<<"What's the weight of pizza:"; cin>>pie.weight; cout<<"company:"<

39、new创建动态结构 #include #include const int Size=20; struct pizza//声明结构 { char company[Size]; double diameter; double weight; }; int main() { using namespace std; pizza *pie=new pizza;//使用new创建动态结构 cout<<"What's the diameter of pizza:"; cin>>pie->diameter; cin.get

40、);//读取下一个字符 cout<<"What's the name of pizza company:"; cin.get(pie->company,Size); cout<<"What's the weight of pizza:"; cin>>pie->weight; cout<<"diameter:"<diameter<<" inches"<company<weight<<" ounches"<

41、 pie;//delete释放内存 return 0; } //ex.4.9 使用new动态分配数组—方法1 #include #include using namespace std; struct CandyBar { string brand; double weight; int calory; }; int main() { CandyBar *snack= new CandyBar[3]; snack[0].brand="A";//单个初始化由new动态分配的内存 snack[0].we

42、ight=1.1; snack[0].calory=200; snack[1].brand="B"; snack[1].weight=2.2; snack[1].calory=400; snack[2].brand="C"; snack[2].weight=4.4; snack[2].calory=500; for(int i=0;i<3;i++) { cout << " brand: " << snack[i].brand << endl; cout << " weight: " << snack[i].weight << endl; c

43、out << " calorie: " << snack[i].calory << endl< int main() { using namespace std; const int Size = 3; int success[Size]; cout<<"Enter your success of the three times 40 meters running:\n"; c

44、in >> success[0]>>success[1]>>success[2]; cout<<"success1:"<

45、ude #include int main() { using namespace std; arrayad={0}; cout<<"Enter your success of the three times 40 meters running:\n"; cin >> ad[0]>>ad[1]>>ad[2]; cout<<"success1:"<

46、 int main() { using namespace std; cout<<"Please enter two integers: "; int num1,num2; cin>>num1>>num2; int sum=0; for(int temp=

47、num1;temp<=num2;++temp)//or temp++ sum+=temp; cout<<"The sum from "< #include int main() { using namespace std; arrayad={0}; ad[1]=ad[0]=1L; for(int i=2;i<10

48、1;i++) ad[i]=i*ad[i-1]; for(int i=0;i<101;i++) cout< int main() { using namespace std; cout<<"Please enter an integer: "; int sum=0,num; while((cin>>num)&&num!=0) { sum+=num;

49、 cout<<"So far, the sum is "< int main() { using namespace std; double sum1,sum2; sum1=sum2=0.0; int year=0; while(sum2<=sum1) { ++year; sum1+=10; sum2=(100+sum2)*0.05+sum2; } cout<<"经过"< const int MONTHS = 12; const char* months[MONTHS

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服