《C++ Primer Plus 第六版》编程练习参考答案(第二章)
2018-12-06 18:15
686 查看
第二章
第一题:
[code]#include <iostream> using namespace std; int main() { cout<<"Horace.Kem"<<" Ganjiang East Road NO.333, Suzhou, Jiangsu, China"; }
第二题:
[code]#include <iostream> using namespace std; int main() { int dist; cout<<"Please enter the distance in long:"; cin>>dist; cout<<"The distance in yards is:"<<220*dist<<endl; }
第三题:
[code]#include <iostream> using namespace std; void fun1(); void fun2(); int main() { fun1(); fun1(); fun2(); fun2(); } void fun1() { cout<<"Three blind mice"<<endl; } void fun2() { cout<<"See how they run"<<endl; }
第四题:
[code]#include <iostream> using namespace std; int main() { int age; cout<<"Enter your age: "; cin>>age; cout<<"The number of months is: "<<12*age<<endl; }
第五题:
[code]#include <iostream> using namespace std; int main() { double Celsius,Fahrenheit; cout<<"Please enter a Celsius value: "; cin>>Celsius; Fahrenheit=1.8*Celsius+32; cout<<Celsius<<" degrees Celsius is "<<Fahrenheit<< " degrees Fahrenheit"<<endl; }
第六题:
[code]#include <iostream> using namespace std; double astro(double); int main() { double lightyear,astronomical; cout<<"Enter the number of light years: "; cin>>lightyear; astronomical=astro(lightyear); cout<<lightyear<<" light years = "<< astronomical<<" astronomical units."<<endl; } double astro(double ly) { return 63240*ly; }
第七题:
[code]#include <iostream> using namespace std; void clock(int,int); int main() { int hours,minutes; cout<<"Enter the number of hours: "; cin>>hours; cout<<"Enter the number of minutes: "; cin>>minutes; clock(hours,minutes); } void clock(int h,int m) { cout<<"Time: "<<h<<":"<<m<<endl; }
相关文章推荐
- C++ Primer Plus (第六版)第六章编程练习参考答案
- c++ primer plus 第六版第二章编程练习答案
- C++ Primer Plus(第六版)第四章编程练习参考答案
- 《C++ Primer Plus 第六版》编程练习参考答案(第四章)
- C++ primer Plus(第六版)中文版 第二章 开始学习C++ 编程练习答案
- C++ Primer Plus第六版 第二章 编程练习答案
- 《C++ Primer Plus 第六版》编程练习参考答案(第六章)
- 《C++ Primer Plus 第六版》编程练习参考答案(第三章)
- c++ primer plus(第6版)中文版 第二章编程练习答案
- C++ primer Plus(第六版)中文版 第三章 处理数据 编程练习答案
- C++ primer plus第六版课后编程练习答案:7.1
- C++ primer Plus(第六版)中文版 第十章 对象和类 编程练习答案
- C++primer plus第六版课后编程练习答案2.2
- c++ primer plus 第六版第三章编程练习答案
- C++primer plus第六版课后编程练习答案5.4
- C++primer plus第六版课后编程练习答案6.4
- C++primer plus第六版课后编程练习答案7.3
- C++primer plus第六版课后编程练习答案10.5
- 《C++ Primer Plus(第六版)》(37)(第十六章 string类和标准模板库 编程练习和答案2)
- C++ primer plus第六版课后编程练习答案:7.2