c++primer 第二章编程练习答案
2.7.1
- #include<iostream>
- int main() {
- using namespace std;
- char name[];
- char address[];
- cout << "input name :";
- cin >> name;
- cout << "input address:";
- cin >> address;
- cin.get();
- cout << "name is " << name;
- cout << endl;
- cout << "address is " << address;
- cin.get();
- }
2.7.2
- #include<iostream>
- int main() {
- using namespace std;
- int distance;
- cout << "input distance:";
- cin >> distance;
- cin.get();
- cout << "long_distance is ";
- cout << distance * ;
- cin.get();
- }
2.7.3
- #include<iostream>
- using namespace std;
- void func_1();
- void func_2();
- int main() {
- //cin.get();
- func_1();
- func_1();
- func_2();
- func_2();
- cin.get();
- }
- void func_1() {
- cout << "Three blind mice" << endl;
- }
- void func_2() {
- cout << "See how they run" << endl;
- }
2.7.4
- #include<iostream>
- int main() {
- using namespace std;
- int age;
- cout << "Enter your age:";
- cin >> age;
- cin.get();
- cout << age * ;
- cin.get();
- }
2.7.5
- #include<iostream>
- double convert(double);
- int main() {
- using namespace std;
- double degrees;
- cout << "Please enter a Celsius value: ";
- cin >> degrees;
- cin.get();
- cout << degrees << " Celsius is " << convert(degrees) << " degrees Fahrenheit";
- cin.get();
- }
- double convert(double degrees) {
- double Fahrenheit = degrees*1.8 + 32.0;
- return Fahrenheit;
- }
2.7.6
- #include<iostream>
- double convert(double);
- int main() {
- using namespace std;
- double light_years;
- cout << "Enter the number of light years: ";
- cin >> light_years;
- cin.get();
- cout << light_years << " light years = " << convert(light_years) << " astronomical units";
- cin.get();
- }
- double convert(double light_years) {
- double units = light_years * ;
- return units;
- }
2.7.7
- #include<iostream>
- void timer(int, int);
- int main() {
- using namespace std;
- int hours, minutes;
- cout << "Enter the number of hours: ";
- cin >> hours;
- cout << "Enter the number of minutes: ";
- cin >> minutes;
- cin.get();
- timer(hours, minutes);
- cin.get();
- }
- void timer(int hours, int minutes) {
- std::cout << "Timer: " << hours << ":" << minutes;
- }
c++primer 第二章编程练习答案的更多相关文章
- Python编程快速上手-让繁琐工作自动化-第二章习题及其答案
Python编程快速上手-让繁琐工作自动化-第二章习题及其答案 1.布尔数据类型的两个值是什么?如何拼写? 答:True和False,使用大写的T和大写的F,其他字母是小写. 2.3个布尔操作符是什么 ...
- C++PRIMER第二章前半部分答案
C++PRIMER第二章前半部分答案 哈哈哈,为什么是前半部分呢,后半部分还在学习中,重新系统性的学习c++,共同进步嘛,不多说,跟我一起来看看吧,第三章开始才是新手收割的时候,慢慢来~~ 2.1&a ...
- C语言程序设计:现代方法(第2版)第二章全部习题答案
前言 本人在通过<C语言程序设计:现代方法(第2版)>自学C语言时,发现国内并没有该书完整的课后习题答案,所以就想把自己在学习过程中所做出的答案分享出来,以供大家参考.这些答案是本人自己解 ...
- 数据结构与算法分析C++表述第二章编程题
把昨天看的第二章巩固一下,做一做编程习题. 2.6: 第一天交2元罚金,以后每一天都是前一天的平方,第N天罚金将是多少? 这个题目和2.4.4-3介绍的幂运算基本一致.若按相同的递归思路分析,比那个问 ...
- C++primer第二章
第二章 :变量和基本类型 2.1 基本内置类型 C++定义了一套包含算术类型(arithmetic type)和空类型(void)在内的基本数据类型 2.1.1 算术类型 算术类型的分类: 整型(in ...
- c++ primer plus 第二章 课后题答案
#include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...
- c++primer 第l六章编程练习答案
6.11.1 #include<iostream> #include<cctype> int main() { using namespace std; char ch; ci ...
- c++primer 第五章编程练习答案
5.9.1 #include<iostream> int main() { using namespace std; ; cout << "input first i ...
- c++primer 第四章编程练习答案
4.13.1 #include<iostream> struct students { ]; ]; char grade; int age; }; int main() { using n ...
随机推荐
- web.xml文件配置说明
web.xml作用: web.xml主要用来配置Filter.Listener.Servlet等,当我们去启动一个WEB项目时,容器(jetty.tomcat等)首先会读取项目web.xml配置文件里 ...
- SAN,NAS区别的联系
在网络存储中,有着各种网络存储解决方案,例如:SAN,NAS,DAS存储网络,它们各自有着各自的特点,其运用场景也有所不同.下面就说说各自的特点. 一.SAN SAN(Storage Area Net ...
- 【HackerRank】Cut the tree
题目链接:Cut the tree 题解:题目要求求一条边,去掉这条边后得到的两棵树的节点和差的绝对值最小. 暴力求解会超时. 如果我们可以求出以每个节点为根的子树的节点之和,那么当我们去掉一条边(a ...
- CSS 命名里面有大学问
其实迟迟不敢开始写关于样式里布局方面的心得, 因为大多数人眼中,哪需要管那么多,只需要最终效果达到了就行了呗. 然而,即使是如今国内外顶级大牛也不敢说自己是个优秀的 CSS 工程师. 一般大公司都是 ...
- php多个数组同键名键值相加合并
//任意多个相同键值的数组合并相加 //预先将所要合并的数组组装成一个新的数组 // $arr = array( // array( // 'user_id' => 100, // 'goods ...
- 高通平台Bootloader启动流程【转】
本文转载自:http://blog.csdn.net/fang_first/article/details/49615631 ====================基本知识============= ...
- Go make 和 new的区别
在Go语言中: make 被用来分配引用类型的内存: map, slice, channel new 被用来分配除了引用类型的所有其他类型的内存: int, string, array等 本文主要给大 ...
- Bootstrap3组件--2
目录 1. 分页 2. 标签 3. 徽章 4. 巨幕 5. 页头 6. 缩略图 7. 警告框 8. 进度条 9. 列表组 10. 面板 11.Well 1. 分页 <!doctype html& ...
- 如何修改windows系统远程桌面默认端口
此文档概述如何修改windows系统远程桌面的默认端口,众所周知windows系统默认的远程桌面端口是3389,这样对于开启远程桌面的计算机有一定的安全威胁,修改远程桌面的默认端口可以提高系统的安全性 ...
- 把已安装的wampserver移动到不同目录使用应注意的问题
很多时候需要把已安装的wampserver移动到不同目录使用,此时应注意几个问题: 1.修改D:\wamp64\bin\apache\apache2.4.9\conf目录下的httpd.conf文件( ...