精心整理 第二章:开始学习C++ //ex2.1--displayyournameandaddress
#include
{
usingnamespacestd;
cout<<\”;
}
//ex2.2--convertthefurlongunitstoyarduints-把浪单位换位码单位
#include
} voidmice()
{
cout<<\
} voidsee()
精心整理
{
cout<<\
} //ex2.4
#include
intmain()
{
usingnamespacestd; cout<<\
intage; cin>>age; intmonth; month=age*12; 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 < return0; } //ex3.2--计算相应的bodymassindex(体重指数) #include 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<<\ 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;
相关推荐: