#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\