【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 ...
随机推荐
- JDBC中级篇(MYSQL)——处理大文本(CLOB)
注意:其中的JdbcUtil是我自定义的连接工具类:代码例子链接: package b_blob_clob; import java.io.FileNotFoundException; import ...
- 并发编程之:synchronized
大家好,我是小黑,一个在互联网苟且偷生的农民工. 之前的文章中跟大家分享了关于Java中线程的一些概念和基本的使用方法,比如如何在Java中启动一个线程,生产者消费者模式等,以及如果要保证并发情况下多 ...
- servlet+Ajax开发web工程
前言 因为目前基本已经不会再用到servlet+jsp开发项目了,基本都是使用框架来开发:我们常用的框架都是基于servlet来封装的,该阶段只需要了解一下tomcat如何使用,servlet的生命周 ...
- canvas二次贝塞尔&三次贝塞尔操作实例
Canvas Quadratic Curve Example canvas = document.getElementById("canvas"); ctx = canvas.ge ...
- js与jquery获取input输入框中的值
如何用javascript获取input输入框中的值,js/jq通过name.id.class获取input输入框中的value 先准备一段 HTML 一.jquery获取input文本框中的值 通过 ...
- SQL查询数据库名、表名、列名
1.获取所有用户名SELECT name FROM Sysusers where status='2' and islogin='1'islogin='1'表示帐户islogin='0'表示角色sta ...
- MySQL之连接查询和子查询
多表连接的基本语法 多表连接,就是将几张表拼接为一张表,然后进行查询 select 字段1, 字段2, ... from 表1 {inner|lift|right} join 表2 on 连接条件; ...
- 基于Linux系统的网络服务——高速缓存DNS及企业级域名解析服务
1.DNS域名系统 DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数 ...
- C语言中动态内存分配的本质是什么?
摘要:C语言中比较重要的就是指针,它可以用来链表操作,谈到链表,很多时候为此分配内存采用动态分配而不是静态分配. 本文分享自华为云社区<[云驻共创]C语言中动态内存分配的本质>,作者: G ...
- CSP-J&S 2020挂分记
应该是退役记 OI 是一门玄学--考后有感 Day -inf 找各科老师请假备考,看着我倒一倒二的好成绩分纷劝我放弃竞赛,成功请到了假. Day -1 怎么莫名其妙大家都在学些奇怪的东西? 跟风写了一 ...