1 void ch2_1() {
2 using namespace std;
3 cout << "xxxxxxxx" << endl;
4 }
5
6 void ch2_2() {
7 using namespace std;
8 double num;
9 cout << "please input a distance in long: ";
10 cin >> num;
11 cout << "it equals " << num * 220 << endl;
12 }
13
14 void ch2_3_1() {
15 using namespace std;
16 cout << "Three blind mice" << endl;
17 }
18
19 void ch2_3_2() {
20 using namespace std;
21 cout << "See how they run" << endl;
22 }
23
24 void ch2_3() {
25 using namespace std;
26 ch2_3_1();ch2_3_1();
27 ch2_3_2();ch2_3_2();
28 }
29
30 void ch2_4() {
31 using namespace std;
32 unsigned int age;
33 cout << "enter your age: ";
34 cin >> age;
35 cout << "months: " << age * 12 << endl;
36 }
37
38 double ch2_5_1(double c){
39 using namespace std;
40 return c * 1.8 + 32;
41 }
42
43 void ch2_5() {
44 using namespace std;
45 double c;
46 cout << "enter a celsius value: ";
47 cin >> c;
48 cout << c << "degrees Celsius is " << ch2_5_1(c) << " degrees Fahrenheit" << endl;
49 }
50
51 double ch2_6_1(double lyear){
52 return lyear * 63240;
53 }
54
55 void ch2_6() {
56 using namespace std;
57 double lyear;
58 cout << "enter the number of light years: ";
59 cin >> lyear;
60 cout << lyear << " light years = " << ch2_6_1(lyear) << " astronomical units" << endl;
61 }
62
63 void ch2_7_1(unsigned int h, unsigned int m){
64 using namespace std;
65 cout << "Time: " << h << ":" << m << endl;
66 }
67
68 void ch2_7() {
69 using namespace std;
70 unsigned int h, m;
71 cout << "enter the number of hours: ";
72 cin >> h;
73 cout << "enter the number of minutes: ";
74 cin >> m;
75 ch2_7_1(h, m);
76 }

【C++ Primer Plus】编程练习答案——第2章的更多相关文章

  1. 【C++ Primer Plus】编程练习答案——第12章

    1 // chapter12_1_cow.h 2 3 4 #ifndef LEARN_CPP_CHAPTER12_1_COW_H 5 #define LEARN_CPP_CHAPTER12_1_COW ...

  2. 【C++ Primer Plus】编程练习答案——第11章 (待更新)

    最近开学,事情较多,过两天更新...

  3. 【C++ Primer Plus】编程练习答案——第10章

    1 // chapter10_1_account.h 2 3 #ifndef LEARN_CPP_CHAPTER10_1_ACCOUNT_H 4 #define LEARN_CPP_CHAPTER10 ...

  4. 【C++ Primer Plus】编程练习答案——第9章

    1 // chapter09_golf.h 2 3 #ifndef LEARN_CPP_CHAPTER09_GOLF_H 4 #define LEARN_CPP_CHAPTER09_GOLF_H 5 ...

  5. 【C++ Primer Plus】编程练习答案——第8章

    1 void ch8_1_print(const std::string & str, int n = 0 ) { 2 using namespace std; 3 static int fl ...

  6. 【C++ Primer Plus】编程练习答案——第7章

    1 double ch7_1_harmonicaverage(double a, double b) { 2 return 2 / (1 / a + 1 / b); 3 } 4 5 void ch7_ ...

  7. 【C++ Primer Plus】编程练习答案——第6章

    1 void ch6_1() { 2 using namespace std; 3 char ch; 4 while ((ch = cin.get()) != '@') { 5 if (isdigit ...

  8. 【C++ Primer Plus】编程练习答案——第5章

    1 void ch5_1() { 2 using namespace std; 3 int small, big, sum{0}; 4 cout << "enter small ...

  9. 【C++ Primer Plus】编程练习答案——第4章

    1 void ch4_1() { 2 using namespace std; 3 string fname, lname; 4 char grade; 5 unsigned int age; 6 c ...

  10. 【C++ Primer Plus】编程练习答案——第3章

    1 void ch3_1() { 2 using namespace std; 3 unsigned int factor = 12; 4 unsigned int inch, feet; 5 cou ...

随机推荐

  1. .net core api 对于FromBody的参数验证

    前言 在framework的mvc中,经常会使用 Model.State . ModelState.IsValid 配合着特性进行参数验证,通过这种方式可以降低controller的复杂度,使用方便. ...

  2. css - 全屏

    css - 全屏 heml和body元素的宽高 html与body都是块元素,但它俩比较特殊,宽高由如下定义: 1.默认的宽度=浏览器可视区域的宽度(不包含滚动条),可设置大于可视区域的宽度,但不会计 ...

  3. HDFS Shell基本操作

    1.目录操作 hdfs dfs [命令]  [命令]         等价于            hadoop fs []  [] 1  ./bin/hdfs dfs -mkdir -p /user ...

  4. HCNP Routing&Switching之OSPF虚连接

    前文我们了解了OSPF的网络类型.帧中继交换机映射以及路由器帧中继映射相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15195762.html:今天我 ...

  5. 编辑器扩展 --- 自动化处理之AssetPostprocessor资源导入

    AssetPostprocessor资源导入管线 AssetPostprocessor用于在资源导入时自动做一些设置,比如当导入大量图片时,自动设置图片的类型,大小等.AssetPostprocess ...

  6. 证明:(a,[b,c]) = [(a,b),(a,c)]

    这题是潘承洞.潘承彪所著<初等数论>(第三版)第一章第5节里一个例题,书中采用算术基本定理证明,并指出要直接用第4节的方法来证是较困难的. 现采用第4节的方法(即最大公约数理论里的几个常用 ...

  7. 【SpringMVC】文件上传与下载、拦截器、异常处理器

    文件下载 使用ResponseEntity实现下载文件的功能 index.html <!DOCTYPE html> <html lang="en" xmlns:t ...

  8. idea字节码插件JClassLib——阅读JVM字节码

    idea字节码插件JClassLib--阅读JVM字节码 生成字节码文件并查看 查看字节码文件的方式:javac 文件名.java 即可生成.class文件,但是这种方式不方便 java:是运行字节码 ...

  9. JDK1.8源码(六)——java.util.ArrayList类

    ArrayList实现了Serializable接口,因此它支持序列化,能够通过序列化传输,实现了RandomAccess接口,支持快速随机访问,实际上就是通过下标序号进行快速访问,实现了Clonea ...

  10. 这篇 Java 基础,我吹不动了

    Hey guys,这里是程序员cxuan,欢迎你收看我最新一期的文章,这篇文章我补充了一些关于<Java基础核心总结>的内容,修改了部分错别字和语句不通顺的地方,并且对内部类.泛型等内容进 ...