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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

C++ primer plus 编程练习25答案.docx

1、C+ primer plus 编程练习25答案C+ primer plus第二章到第五章编程练习答案 第二章1:#include#define max 10using namespace std;void main() char namemax,dizhimax; coutname; coutdizhi; coutnamedizhiendl;2:#includeusing namespace std;void main() long juli; coutjuli; cout按照您输入的距离是:juli*220码endl; 3:#includeusing namespace std;void b

2、lind() coutThree blind micen;void run() coutSee how they runn;void main() for(int i=0;i2;i+) blind(); for(int j=0;j2;j+) run();4:#includeusing namespace std;void month(int age) cout该年龄一共包含age*12个月!n;void main() int age; coutage; month(age);5:#includeusing namespace std;double fahrenheit(double celsi

3、us) return 1.8*celsius+32.0;void main() double celsius; coutcelsius; coutcelsius degrees celsius is fahrenheit(celsius) degrees fahrenheit.n;6:#includeusing namespace std;double astronomical(double light) return 63240*light;void main() double light; coutlight; coutlight light years = astronomical(li

4、ght) astronomical units.n;7:#includeusing namespace std;void display(int hours,int minutes) coutTime: hours:minutesendl;void main() int hour,minute; couthour; coutminute; display(hour,minute); 第三章1:#includeusing namespace std;const float danwei=0.0833333;void iswap(int cun) cout您的身高为: cun*danwei 英尺!

5、endl;void main() int cun; coutcun; iswap(cun);2:#includeusing namespace std;const double yingchi=12;const double bang=2.2;const double memter=0.0245;void caculate(double chi,double cun,double weight) double BMI; double yingcun,mi,qianke; yingcun=cun+chi*yingchi; mi=yingcun*memter; qianke=weight/bang

6、; BMI=qianke/(mi*mi); cout您的BMI值为: BMIendl;void main() double chi,cun,weight; coutchicun; coutweight; caculate(chi,cun,weight);3:#includeusing namespace std;void main() double degrees,minutes,seconds,sum; coutEnter a latitude in degrees,minutes,and seconds:endl; coutdegrees; coutminutes; coutseconds

7、; sum=degrees+minutes/60+seconds/3600; coutdegrees degrees,minutes minutes,seconds seconds= sum degrees.endl;4:#includeusing namespace std;const long m=60;const long h=60;const long d=24;int sumday(long seconds) long hour,minute; minute=seconds/m; hour=minute/h; return hour/d;int sumhour(long second

8、s,int day) long minute; seconds=seconds-day*d*h*m; minute=seconds/m; return minute/h;int summinute(long seconds,int day,int hour) seconds=seconds-(day*d*h*m+hour*h*m); return seconds/m;int sumsecond(long seconds,int day,int hour,int minute) return seconds=seconds-(day*d*h*m+hour*h*m+minute*m);void m

9、ain() long seconds; int day,hour,minute,second; coutseconds; day=sumday(seconds); hour=sumhour(seconds,day); minute=summinute(seconds,day,hour); second=sumsecond(seconds,day,hour,minute); coutseconds seconds = day days,hour hours,minute minutes,second seconds.endl;5:#includeusing namespace std;void

10、main() double world,us; coutworld; coutus; double bilv; bilv=us/world; coutThe population of the us is bilv% of the world population.endl;6:#includeusing namespace std;void main() float memter,jialun; cout以美国风格还是欧洲风格显示耗油量?m为美国,o为欧洲!endl; coutc; if(c=m) coutmemter; coutjialun; cout汽车耗油量为:memter/jialu

11、nmpg.endl; else coutmemter; coutjialun; float ofg; ofg=(100*jialun)/memter; cout汽车耗油量为:ofgL/100Km.endl; 7:includeusing namespace std;void main() coutofg; float jialun; jialun=ofg/3.875; float haoyou; haoyou=62.14/jialun; cout转换成美国风格的耗油量(一加仑的里程,mpg):haoyoumpg.endl; 第四章1:#include#includeconst int num=

12、10;using namespace std;int main() coutWhats your first name?; char firstnum; cin.getline(first,num); coutlast; coutgrade; coutage; cout-endl; coutName: last,firstendl; coutGrade: char (grade+1)endl; coutAge: ageendl; return 0;2:#include#includeusing namespace std;int main() string name,dessert; cout

13、Enter your name:n; getline(cin,name); cin.get(); coutEnter your favorite dessert:n; getline(cin,dessert); coutI have some delicious dessert for you, name.n; return 0; 3:#include#includeusing namespace std;int main() coutfirst; coutlast; strcat(last, ); strcat(last,first); coutHeres the information i

14、n a single string: lastendl; return 0; 4:include#includeusing namespace std;int main() coutfirst; coutlast; last=last+, ; last=last+first; coutHeres the information in a single string: lastendl; return 0; 5:#include#includeusing namespace std;struct CandyBar char brand20; double weight; long calorie

15、s;int main() CandyBar snack= Mocha Munch,2.3,350 ; coutsnack.brandendl; coutsnack.weightendl; coutsnack.caloriesendl; return 0; 6:#include#includeusing namespace std;struct CandyBar char brand20; double weight; long calories;int main() CandyBar snack3= Mocha Munch,2.3,350 , caorui,3.6,456 , denger,4

16、.7,877 ; for(int i=0;i3;i+) cout-endl; coutsnacki.brandendl; coutsnacki.weightendl; coutsnacki.caloriesendl; cout-endl; return 0; 7:#include#include#includeusing namespace std;struct pizza string company; double diameter; double weight;int main() pizza p; coutPlease input the company of manufacture

17、pizza: ; getline(cin,pany); coutp.diameter; coutp.weight; coutName : pany,and the company name is form of pany.size() words.endl; coutDiameter: p.diameterendl; coutWeight: p.weightendl; return 0; 8:#include#include#includeusing namespace std;struct pizza string company; double diameter; double weigh

18、t;int main() pizza *p=new pizza; coutp-diameter; cin.get(); coutcompany); coutp-weight; coutName : company,and the company name is form of company.size() words.endl; coutDiameter: diameterendl; coutWeight: weightendl; return 0; 9:#include#includeusing namespace std;struct CandyBar char brand20; doub

19、le weight; long calories;int main() CandyBar *snack=new CandyBar3; strcpy(snack-brand,shanghai); snack-weight=1.2; snack-calories=7; strcpy(snack+1)-brand,beijing); (snack+1)-weight=2.3; (snack+1)-calories=8; strcpy(snack+2)-brand,guangzhou); (snack+2)-weight=3.4; (snack+2)-calories=9; for(int i=0;i

20、3;i+) cout-endl; coutsnacki.brandendl; coutsnacki.weightendl; coutsnacki.caloriesendl; cout-endl; return 0; 10:#include#includeusing namespace std;int main() double grade3; coutPlease input three grades of running.endl; for(int i=0;i3;i+) coutThe i+1gradei; cout一共跑了3次,平均成绩为: (grade0+grade1+grade2)/3

21、 码.endl; return 0; 第五章1:#includeusing namespace std;int main() int x,y; coutplease input two numbers.xy; double sum=0; for(int i=x;i=y;i+) sum+=i; coutx to y sums is: sumendl; system(pause); return 0;2:#includeusing namespace std;int main() long double jiechen=1; for(int i=2;i=100;i+) jiechen=i*jiechen; cout100!=jiechenendl; system(pause); return 0;3:

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

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