【C++ Primer Plus】编程练习答案——第2章
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章的更多相关文章
- 【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 ...
- 【C++ Primer Plus】编程练习答案——第11章 (待更新)
最近开学,事情较多,过两天更新...
- 【C++ Primer Plus】编程练习答案——第10章
1 // chapter10_1_account.h 2 3 #ifndef LEARN_CPP_CHAPTER10_1_ACCOUNT_H 4 #define LEARN_CPP_CHAPTER10 ...
- 【C++ Primer Plus】编程练习答案——第9章
1 // chapter09_golf.h 2 3 #ifndef LEARN_CPP_CHAPTER09_GOLF_H 4 #define LEARN_CPP_CHAPTER09_GOLF_H 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 ...
- 【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_ ...
- 【C++ Primer Plus】编程练习答案——第6章
1 void ch6_1() { 2 using namespace std; 3 char ch; 4 while ((ch = cin.get()) != '@') { 5 if (isdigit ...
- 【C++ Primer Plus】编程练习答案——第5章
1 void ch5_1() { 2 using namespace std; 3 int small, big, sum{0}; 4 cout << "enter small ...
- 【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 ...
- 【C++ Primer Plus】编程练习答案——第3章
1 void ch3_1() { 2 using namespace std; 3 unsigned int factor = 12; 4 unsigned int inch, feet; 5 cou ...
随机推荐
- IPython中也要保持优雅(DRY原则)
What is IPython? IPython provides a rich architecture for interactive computing with: A powerful int ...
- Go并发控制--WaitGroup篇
目录 1. 前言 2. 使用WaitGroup控制 2.1 使用场景 2.2 信号量 1.3 WaitGroup 数据结构 2.3.1 Add () 方法 2.3.2 Wait() 2.3.3 Don ...
- 【Tools】Anaconda Operaction
专为数据科学和机器学习工作流程而设计,是一个开源包管理器,环境管理器,以及Python和R编程语言的分发.它通常用于大规模数据处理,科学计算和预测分析.pip install xxx ,在特定环境里使 ...
- Spring笔记(1)
Spring快速入门 开发步骤 导入坐标 <dependency> <groupId>org.springframework</groupId> <artif ...
- Shell脚本一键部署——源码编译安装MySQL及自动补全工具
Shell脚本一键部署--源码编译安装MySQL及自动补全工具 编译安装MySQL 1.软件包 Mysql安装包 将安装包拖至/opt目录下,编辑一个脚本文件,将以下内容复制进去,然后source或者 ...
- 知乎大佬图文并茂的epoll讲解,看不懂的去砍他
select.poll.epoll的文章很多,自己也看过不少经典好文.不过第一次看到讲的如此通俗易懂.又图文并茂的.因此拿来分享下,供后续翻看学习. 原文链接:https://zhuanlan.zhi ...
- MobaXterm - 渗透之旅的终端神器
一.背景 1.SSH概念 如果想要连接Linux服务器来进行文件之间的传送,那就需要一个Secure Shell软件(简称SSH的)来完成.从概念上来讲,SSH其实是一个网络协议,允许通过网络连接到L ...
- Java基础学习3
Java语法学习3 基本运算符 关系运算符返回结果为布尔类型 %:取余 模运算 +.-.*./.% :二元运算符 两个变量间的运算 ++.-- 一元运算符 package Study; public ...
- NPOI相关资料
http://blog.csdn.net/heyangyi_19940703/article/details/52292755 http://www.cnblogs.com/zhengjuzhuan/ ...
- 自定义cs程序安装界面
http://www.crifan.com/achieve_fixed_install_path_while_install_software_when_make_msi_installer/ 制作C ...