【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 ...
随机推荐
- (一)响应式web设计。。。freecodecamp笔记
HTML基础 HTML 的全称是 HyperText Markup Language(超文本标记语言),它是一种用来描述网页结构的标记语言. h1用作主标题,h2用作副标题,还有h3.h4.h5.h6 ...
- SpringCloud之网关zuul
1.微服务网关介绍和使用场景 1)什么是网关 API Gateway,是系统的唯一对外的入口,介于客户端和服务器端之间的中间层,处理非业务功能 提供路由请求.鉴权.监控.缓存.限流等功能 统一接入 智 ...
- Ubuntu防火墙:ufw
原始linux的防火墙是iptables,以为过于繁琐,各个发行版几乎都有自己的方案; ubuntu下的防火墙是ufw[ubuntu fireward的缩写],centos的防火墙是fireward ...
- apche的BeanUtils避免使用!
原文出处 建议,不要使用apache的BeanUtils进行属性拷贝了,建议使用Spring 核心包bean下面的BeanUtils进行替代! 使用和对比出处
- jQuery中的文档操作处理(五):append()、prepend()、after()、before()、wrap()、wrapAll()、wrapInner()、clone()等
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- 算法入门 - 链表的实现及应用(Java版本)
之前我们学习了动态数组,虽然比原始数组的功能强大了不少,但还不是完全纯动态的(基于静态数组实现的).这回要讲的链表则是正儿八经的动态结构,是一种非常灵活的数据结构. 链表的基本结构 链表由一系列单一的 ...
- hdfs数据迁移
有时候可能会进行hadoop集群数据拷贝的情况,可用以下命令进行拷贝 需要在目标集群上来进行操作 hadoop distcp hdfs://192.168.1.233:8020/user/hive/w ...
- MySQL的几种锁机制的使用介绍
锁 在日常的开发过程中,为了控制线程的并发肯定会用到锁机制.对于数据库而言,锁机制就是数据库为了保证数据的一致性,而使各种共享资源在被并发访问变得有序所设计的一种规则.当然MySQL也不例外,根据不同 ...
- Linux(二)——常用命令
一.一般指令 立刻关机:shutdown -h now 1分钟后关机:shutdown -h 1 立刻重启:shutdown -r now 立刻关机:halt 立刻重启:reboot 把内存的数据同步 ...
- Linux常用命令 - nl命令详解
21篇测试必备的Linux常用命令,每天敲一篇,每次敲三遍,每月一循环,全都可记住!! https://www.cnblogs.com/poloyy/category/1672457.html 显示行 ...