2.7.1

  1. #include<iostream>
  2. int main() {
  3. using namespace std;
  4. char name[];
  5. char address[];
  6. cout << "input name :";
  7. cin >> name;
  8. cout << "input address:";
  9. cin >> address;
  10. cin.get();
  11. cout << "name is " << name;
  12. cout << endl;
  13. cout << "address is " << address;
  14. cin.get();
  15. }

2.7.2

  1. #include<iostream>
  2. int main() {
  3. using namespace std;
  4. int distance;
  5. cout << "input distance:";
  6. cin >> distance;
  7. cin.get();
  8. cout << "long_distance is ";
  9. cout << distance * ;
  10. cin.get();
  11. }

2.7.3

  1. #include<iostream>
  2. using namespace std;
  3. void func_1();
  4. void func_2();
  5. int main() {
  6. //cin.get();
  7. func_1();
  8. func_1();
  9. func_2();
  10. func_2();
  11. cin.get();
  12. }
  13. void func_1() {
  14. cout << "Three blind mice" << endl;
  15. }
  16. void func_2() {
  17. cout << "See how they run" << endl;
  18. }

2.7.4

  1. #include<iostream>
  2. int main() {
  3. using namespace std;
  4. int age;
  5. cout << "Enter your age:";
  6. cin >> age;
  7. cin.get();
  8. cout << age * ;
  9. cin.get();
  10. }

2.7.5

  1. #include<iostream>
  2. double convert(double);
  3. int main() {
  4. using namespace std;
  5. double degrees;
  6. cout << "Please enter a Celsius value: ";
  7. cin >> degrees;
  8. cin.get();
  9. cout << degrees << " Celsius is " << convert(degrees) << " degrees Fahrenheit";
  10. cin.get();
  11. }
  12. double convert(double degrees) {
  13. double Fahrenheit = degrees*1.8 + 32.0;
  14. return Fahrenheit;
  15. }

2.7.6

  1. #include<iostream>
  2. double convert(double);
  3. int main() {
  4. using namespace std;
  5. double light_years;
  6. cout << "Enter the number of light years: ";
  7. cin >> light_years;
  8. cin.get();
  9. cout << light_years << " light years = " << convert(light_years) << " astronomical units";
  10. cin.get();
  11. }
  12. double convert(double light_years) {
  13. double units = light_years * ;
  14. return units;
  15. }

2.7.7

  1. #include<iostream>
  2. void timer(int, int);
  3. int main() {
  4. using namespace std;
  5. int hours, minutes;
  6. cout << "Enter the number of hours: ";
  7. cin >> hours;
  8. cout << "Enter the number of minutes: ";
  9. cin >> minutes;
  10. cin.get();
  11. timer(hours, minutes);
  12. cin.get();
  13. }
  14. void timer(int hours, int minutes) {
  15. std::cout << "Timer: " << hours << ":" << minutes;
  16. }

c++primer 第二章编程练习答案的更多相关文章

  1. Python编程快速上手-让繁琐工作自动化-第二章习题及其答案

    Python编程快速上手-让繁琐工作自动化-第二章习题及其答案 1.布尔数据类型的两个值是什么?如何拼写? 答:True和False,使用大写的T和大写的F,其他字母是小写. 2.3个布尔操作符是什么 ...

  2. C++PRIMER第二章前半部分答案

    C++PRIMER第二章前半部分答案 哈哈哈,为什么是前半部分呢,后半部分还在学习中,重新系统性的学习c++,共同进步嘛,不多说,跟我一起来看看吧,第三章开始才是新手收割的时候,慢慢来~~ 2.1&a ...

  3. C语言程序设计:现代方法(第2版)第二章全部习题答案

    前言 本人在通过<C语言程序设计:现代方法(第2版)>自学C语言时,发现国内并没有该书完整的课后习题答案,所以就想把自己在学习过程中所做出的答案分享出来,以供大家参考.这些答案是本人自己解 ...

  4. 数据结构与算法分析C++表述第二章编程题

    把昨天看的第二章巩固一下,做一做编程习题. 2.6: 第一天交2元罚金,以后每一天都是前一天的平方,第N天罚金将是多少? 这个题目和2.4.4-3介绍的幂运算基本一致.若按相同的递归思路分析,比那个问 ...

  5. C++primer第二章

    第二章 :变量和基本类型 2.1 基本内置类型 C++定义了一套包含算术类型(arithmetic type)和空类型(void)在内的基本数据类型 2.1.1 算术类型 算术类型的分类: 整型(in ...

  6. c++ primer plus 第二章 课后题答案

    #include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...

  7. c++primer 第l六章编程练习答案

    6.11.1 #include<iostream> #include<cctype> int main() { using namespace std; char ch; ci ...

  8. c++primer 第五章编程练习答案

    5.9.1 #include<iostream> int main() { using namespace std; ; cout << "input first i ...

  9. c++primer 第四章编程练习答案

    4.13.1 #include<iostream> struct students { ]; ]; char grade; int age; }; int main() { using n ...

随机推荐

  1. web.xml文件配置说明

    web.xml作用: web.xml主要用来配置Filter.Listener.Servlet等,当我们去启动一个WEB项目时,容器(jetty.tomcat等)首先会读取项目web.xml配置文件里 ...

  2. SAN,NAS区别的联系

    在网络存储中,有着各种网络存储解决方案,例如:SAN,NAS,DAS存储网络,它们各自有着各自的特点,其运用场景也有所不同.下面就说说各自的特点. 一.SAN SAN(Storage Area Net ...

  3. 【HackerRank】Cut the tree

    题目链接:Cut the tree 题解:题目要求求一条边,去掉这条边后得到的两棵树的节点和差的绝对值最小. 暴力求解会超时. 如果我们可以求出以每个节点为根的子树的节点之和,那么当我们去掉一条边(a ...

  4. CSS 命名里面有大学问

    其实迟迟不敢开始写关于样式里布局方面的心得, 因为大多数人眼中,哪需要管那么多,只需要最终效果达到了就行了呗. 然而,即使是如今国内外顶级大牛也不敢说自己是个优秀的 CSS 工程师. 一般大公司都是 ...

  5. php多个数组同键名键值相加合并

    //任意多个相同键值的数组合并相加 //预先将所要合并的数组组装成一个新的数组 // $arr = array( // array( // 'user_id' => 100, // 'goods ...

  6. 高通平台Bootloader启动流程【转】

    本文转载自:http://blog.csdn.net/fang_first/article/details/49615631 ====================基本知识============= ...

  7. Go make 和 new的区别

    在Go语言中: make 被用来分配引用类型的内存: map, slice, channel new 被用来分配除了引用类型的所有其他类型的内存: int, string, array等 本文主要给大 ...

  8. Bootstrap3组件--2

    目录 1. 分页 2. 标签 3. 徽章 4. 巨幕 5. 页头 6. 缩略图 7. 警告框 8. 进度条 9. 列表组 10. 面板 11.Well 1. 分页 <!doctype html& ...

  9. 如何修改windows系统远程桌面默认端口

    此文档概述如何修改windows系统远程桌面的默认端口,众所周知windows系统默认的远程桌面端口是3389,这样对于开启远程桌面的计算机有一定的安全威胁,修改远程桌面的默认端口可以提高系统的安全性 ...

  10. 把已安装的wampserver移动到不同目录使用应注意的问题

    很多时候需要把已安装的wampserver移动到不同目录使用,此时应注意几个问题: 1.修改D:\wamp64\bin\apache\apache2.4.9\conf目录下的httpd.conf文件( ...