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 ...
随机推荐
- python 获取当前运行的 class 和 方法的名字
# coding=utf-8 import sys class Hello(): def hello(self): print('the name of method is ## {} ##'.for ...
- spring boot 2.0添加对fastjson的支持
首先引入fastjson的maven依赖: <dependency> <groupId>com.alibaba</groupId> <artifactId&g ...
- 剑指offer 面试62题
面试62题: 题目:圆圈中最后剩下的数字 题:0,1,...,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字.求出这个圆圈里剩下的最后一个数字. 解题思路:约瑟夫环问题,可 ...
- LVS Nginx Haproxy对比
一般对负载均衡的使用是随着网站规模的提升根据不同的阶段来使用不同的技术. 具体的应用需求还得具体分析,如果是中小型的Web应用,比如日PV小于1000万,用Nginx就完全可以了: 如果机器不少,可以 ...
- 【转】Python爬虫(3)_Beautifulsoup模块
一 介绍 Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beautiful Soup会帮你 ...
- windows 2008 负载均衡(NLB) 问题汇总
1. 主机不可访问 修改host文件. 将主机名与IP做相应的映射. 它们应该是使用主机名来访问对应的服务器. host文件路径: C:\Windows\System32\drivers\etc 19 ...
- yield 表达式形式的应用
import random foods=['banana','apple','peach','grape','pear'] def deco(func): def wrapper(*args,**kw ...
- OC中NSSet去重细节
我们都知道,NSSet在存储数据时,不允许存储相同数据?那么,这里的相同该如何理解呢? 很多人都简单的理解为按照其存储对象的内存地址进行评判.其实不然.经过个人实验证明:当类型为NSString,NS ...
- C语言中static的使用方法【转】
本文转自:http://blog.csdn.net/renren900207/article/details/21609649 全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量 ...
- 【转载】如何简单地理解Python中的if __name__ == '__main__'
原帖:https://blog.csdn.net/yjk13703623757/article/details/77918633 通俗的理解__name__ == '__main__':假如你叫小明. ...