c++primerplus(µÚÁù°æ)¿Îºó±à³ÌÁ·Ï°´ð°¸ ÏÂÔر¾ÎÄ

. .

µÚ¶þÕ£º¿ªÊ¼Ñ§Ï°C++

//ex2.1--display your name and address #include int main(void) {

using namespace std;

cout<<\¡±£» }

//ex2.2--convert the furlong units to yard uints-°ÑÀ˵¥Î»»»Î»Â뵥λ #include double fur2yd(double); int main() {

using namespace std;

cout<<\ double fur; cin>>fur;

cout<<\

double yd;

yd=fur2yd(fur);

cout<

double fur2yd(double t) {

return 220*t; }

//ex2.3-ÿ¸öº¯Êý¶¼±»µ÷ÓÃÁ½´Î #include void mice(); void see();

using namespace std; int main() {

mice(); mice(); see(); see(); return 0; }

wordÍêÃÀ¸ñʽ

. .

void mice() {

cout<<\}

void see() {

cout<<\ }

//ex2.4

#include int main() {

using namespace std; cout<<\ int age; cin>>age; int month; month=age*12;

cout<

//ex2.5---convert the Celsius valve to Fahrenheit value #include double C2F(double); int main() {

using namespace std;

cout<<\double C; cin>>C; double F; F=C2F(C);

cout<

double C2F(double t) {

return 1.8*t+32; }

wordÍêÃÀ¸ñʽ

. .

//ex2.6---convert the light years valve to astronomical units--°Ñ¹âÄêת»»ÎªÌìÎĵ¥Î»

#include

double convert(double);//º¯ÊýÔ­ÐÍ int main() {

using namespace std;

cout<<\double light_years; cin>>light_years; double astro_units;

astro_units=convert(light_years);

cout<

double convert(double t) {

return 63240*t;//1 ¹âÄê=63240 ÌìÎĵ¥Î» }

//ex2.7--ÏÔʾÓû§ÊäÈëµÄСʱÊýºÍ·ÖÖÓÊý #include void show(); main() {

using namespace std; show(); return 0; }

void show() {

using namespace std; int h,m;

cout<<\cin>>h;

cout<<\cin>>m;

cout<<\ }

µÚÈýÕ£º´¦ÀíÊý¾Ý

wordÍêÃÀ¸ñʽ