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

cprimerplus第六版课后编程练习答案

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

#include

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<

cout<<\

cout<<\身高:\英尺inch)\\n\身高:\米meter)\\n\

<<\体重:\千克kilogram)\\n\

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