第二章:开始学习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< return0; } doublefur2yd(doublet) { return220*t; } //ex2.3-每个函数都被调用两次 #include 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< return0; } //ex2.5---converttheCelsiusvalvetoFahrenheitvalue #include doubleC2F(double); intmain() { usingnamespacestd; cout<<\ doubleC; cin>>C; doubleF; F=C2F(C); cout< return0; } doubleC2F(doublet) { return1.8*t+32; } //ex2.6---convertthelightyearsvalvetoastronomicalunits--把光年转换为天文单位