1 2 3 4 5 6 7 8
}
第二章:开始学习C++
//ex2.1--display your name and address #include
using namespace std;
cout<<\”;
9 10 11 12 13 14 15 16 17 18
//ex2.2--convert the furlong units to yard uints-把浪单位换位码单位 #include
using namespace std;
cout<<\ double fur; cin>>fur;
1
19 20 21 22
cout<<\ double yd; yd=fur2yd(fur);
cout< return 0; 24 25 } 26 double fur2yd(double t) 27 { 28 return 220*t; 29 30 } 31 32 //ex2.3-每个函数都被调用两次 33 #include using namespace std; 2 37 38 39 40 41 42 43 44 int main() { } mice(); mice(); see(); see(); return 0; 45 46 47 48 49 } void mice() { cout<<\ 50 51 52 53 54 void see() { cout<<\ 3 55 } 56 57 58 59 60 61 62 63 64 65 66 67 68 69 //ex2.4 #include using namespace std; cout<<\ int age; cin>>age; int month; month=age*12; cout< 70 71 72 //ex2.5---convert the Celsius valve to Fahrenheit value #include 4 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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; } 89 90 //ex2.6---convert the light years valve to astronomical units--把光 5