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 ...
随机推荐
- (4.11)sql server内存使用
一些内存使用错误理解 开篇小感悟 在实际的场景中会遇到各种奇怪的问题,为什么会感觉到奇怪,因为没有理论支撑的东西才感觉到奇怪,SQL Server自己管理内存,我们可以干预的方式也很少,所以日常很 ...
- 中文价格识别为数字 java代码
运行效果: public class VoicePriceRecognition { private final static String NOT_HAS_PRICE_CONTENT="n ...
- Javascript 广告浮动效果在浏览器中间N秒后移动到右下角
Javascript 广告浮动效果在浏览器中间N秒后移动到右下角 闲着无聊做了一个,本人原创...就是这个页面的广告效果....怎么样???? 刚刚学习的javascript
- Git处理 行结束符
Dealing with line endings (Windows) 如果你正在使用Git在GitHub上和别人协作的话,确保Git处理行结束符的配置已经正确配置了. 每次在键盘上按下return键 ...
- 定制AIX操作系统的shell环境
操作系统与外部最主要的接口就叫做shell.shell是操作系统最外面的一层.shell管理你与操作系统之间的交互:等待你输入,向操作系统解释你的输入,并且处理各种各样的操作系统的输出结果. shel ...
- Linux静默安装weblogic
本实验安装weblogic10系列版本 #创建weblogic用户组. [root@admin /]# groupadd weblogic[root@admin /]# useradd -g webl ...
- for循环执行流程
语句格式: for(表达式1;表达式2;表达式3) { 循环体 } 表达式1:赋值表达式,用来给控制变量赋初值.(只执行一次) 表达式2:逻辑表达式,是循环的控制条件,用来判断控制变量是否符合循环条件 ...
- problem-1003(恢复一下)
问题: Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequenc ...
- iOS面试必备-iOS基础知识
近期为准备找工作面试,在网络上搜集了这些题,以备面试之用. 插一条广告:本人求职,2016级应届毕业生,有开发经验.可独立开发,低薪求职.QQ:895193543 1.简述OC中内存管理机制. 答:内 ...
- linux下安装编译网卡驱动的方法
安装linux操作系统后发现没有网卡驱动,表现为 system → Administration → Network下Hardware列表为空. 以下为安装编译网卡驱动的过程,本人是菜鸟,以下是我从网 ...