第一范文网 - 专业文章范例文档资料分享平台

c++primerplus(第六版)课后编程练习测试参考答案

来源:用户分享 时间:2025/8/8 11:14:15 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

精心整理 第二章:开始学习C++ //ex2.1--displayyournameandaddress

#include intmain(void)

{

usingnamespacestd;

cout<<\”;

}

//ex2.2--convertthefurlongunitstoyarduints-把浪单位换位码单位

#include doublefur2yd(double); intmain() { usingnamespacestd; cout<<\ doublefur; cin>>fur; cout<<\doubleyd; yd=fur2yd(fur); cout< voidmice(); voidsee(); usingnamespacestd; intmain() { mice(); mice(); see(); see(); return0;

} voidmice()

{

cout<<\

} voidsee()

精心整理

{

cout<<\

} //ex2.4

#include

intmain()

{

usingnamespacestd; cout<<\

intage; cin>>age; intmonth; month=age*12; cout< doubleC2F(double); intmain() { usingnamespacestd; cout<<\doubleC; cin>>C; doubleF; F=C2F(C); cout<

doubleconvert(double);//函数原型

intmain()

{

usingnamespacestd;

cout<<\

doublelight_years; cin>>light_years; doubleastro_units;

astro_units=convert(light_years);

cout<

return0;

精心整理

}

doubleconvert(doublet)

{

return63240*t;//1光年=63240天文单位

}

//ex2.7--显示用户输入的小时数和分钟数

#include

voidshow(); main() {

usingnamespacestd;

show(); return0; } voidshow() { usingnamespacestd; inth,m; cout<<\cin>>h; cout<<\cin>>m; cout<<\} 第三章:处理数据 //ex3.1—将身高用英尺(feet)和英寸(inch)表示 #include constintinch_per_feet=12;//const常量--1feet=12inches--1英尺=12英寸 intmain() { usingnamespacestd; cout<<\表示为退格字符 intht_inch; cin>>ht_inch; intht_feet=ht_inch/inch_per_feet;//取商 intrm_inch=ht_inch%inch_per_feet;//取余 cout<<\

<

return0;

}

//ex3.2--计算相应的bodymassindex(体重指数)

#include constintinch_per_feet=12;

constdoublemeter_per_inch=0.0254; constdoublepound_per_kilogram=2.2;

intmain()

{

精心整理 usingnamespacestd;

cout<<\

cout<<\(输入你身高的英尺部分):_\\b\

intht_feet; cin>>ht_feet;

cout<<\(输入你身高的英寸部分):_\\b\

intht_inch; cin>>ht_inch;

cout<<\

doublewt_pound; cin>>wt_pound;

intinch; inch=ht_feet*inch_per_feet+ht_inch; doubleht_meter; ht_meter=inch*meter_per_inch; doublewt_kilogram; wt_kilogram=wt_pound/pound_per_kilogram; cout< constintminutes_per_degree=60; constintseconds_per_minute=60; intmain() { usingnamespacestd; cout<<\ cout<<\ intdegree; cin>>degree;

cout<<\

intminute; cin>>minute;

cout<<\

intsecond; cin>>second; doubleshow_in_degree;

show_in_degree=(double)degree+(double)minute/minutes_per_degree+(double)second/minutes_per_

degree/seconds_per_minute;

c++primerplus(第六版)课后编程练习测试参考答案.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6756v89p156trx01723y3gzju6vsnw00djk_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top