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常见序列详解
一.Python中序列的分类 常见序列类型包括字符串(普通字符串和unicode字符串),列表和元组.所谓序列,即成员有序排列,可通过下标访问. 二.Python序列通用操作 下面我们将分别以字符串. ...
- LeetCode-11-7
1.Reverse String Write a function that takes a string as input and returns the string reversed. Exam ...
- C语言转义字符的使用方法
cppreference.com -> 转义字符 常量转义字符 以下的转义字符使普通字符表示不同的意义. 转义字符 描述 \' 单引号 \" 双引号 \\ 反斜杠 \0 空字符 \a ...
- Android开发问题:ActivityNotFoundException: Unable to find explicit activity class
http://blog.csdn.net/debuglog/article/details/7236013 原因:AndroidManifest.xml未添加对应Activity配置. 解决办法:在A ...
- CuteEditor.Editor+a+a+c+a+a.a() System.RuntimeType.get_Assembly() 问题解决方法
问题: Server Error in '/' Application. Attempt by method 'CuteEditor.Editor+a+a+c+a+a.a()' to access m ...
- UVA11297 Census
题目 UVA11297 Census 做法 二维线段树,单点修改,矩阵查询,树套树(\(x,y\)),维护最大值最小值废话 有一点要注意的是:\(x\)树传到\(y\)树里面修改的时候,如果\(x\) ...
- 纯CSS3动画按钮效果
在线演示 本地下载
- B-树 C++模板类封装(有图有真相)
定义: 一棵m阶B-树是拥有以下性质的多路查找树: 1.非叶子结点的根结点至少拥有两棵子树: 2.每一个非根且非叶子的结点含有k-1个关键字以及k个子树,其中⌈m/2⌉≤k≤m: 3.每一个叶子结点都 ...
- 用requests登录微信网页版,并接收发送消息
首先,网页版微信登录大致分为以下几个流程(都是大家可以通过抓包得到): 1.登陆主页后,会生成一个UUID,这是个用户标识,在后面请求二维码会用到 def get_uuid(self): '''获取u ...
- Unity 简易监听框架
全局维护一个字典,字典中的key为字符串或者自定义类型,value为委托, using System.Collections; using System.Collections.Generic; us ...