3.7.1

#include<iostream>
int main() {
using namespace std;
const int unit = ;
int height,inch,foot;
cout << "please input your height __ inch\b\b\b\b\b\b\b";
cin >> height;
inch = height % unit;
foot = height / unit;
cin.get();
cout << "your height is " << foot << " foot " << inch << " inch";
cin.get();
}

3.7.2

#include<iostream>
int main() {
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield);
const double inch_to_meter = 0.0254;
const double kg_to_lb = 2.2;
int inch, foot, lb;
//float height, weight;
cout << "please input your height!\n";
cout << "foot:_\b";
cin >> foot;
cout << "inch:_\b";
cin >> inch;
cout << "please input your weight " << "___ lb\b\b\b\b\b\b";
cin >> lb;
cin.get();
cout << "your height is " << foot * + inch << " inch\n";
cout << "your height is " << (foot * + inch)*inch_to_meter << "m\n";
cout << "your weight is " << lb / 2.2 << "kg\n";
cout << "your BMI is " << pow((lb / 2.2) / ((foot * + inch)*inch_to_meter), );
//cout << pow(2, 3);
cin.get();
}

3.7.3

#include<iostream>
int main() {
using namespace std;
const int degree_to_minute = ;
const int minute_to_second = ;
int degree, minute, second;
double latitude;
cout << "Enter a latitude in degree,minutes,and seconds:\n";
cout << "First,enter the degrees: ";
cin >> degree;
cout << "Next,enter the minutes of arc: ";
cin >> minute;
cout << "Finally,enter the seconds of arc: ";
cin >> second;
cin.get();
latitude = degree + double(minute) / degree_to_minute + double(second) / degree_to_minute / minute_to_second;
cout << degree << " degrees," << minute << " minutes," << second << " seconds = " << latitude << " degrees";
cin.get();
}

3.7.4

#include<iostream>
int main() {
using namespace std;
const int days_to_hours = ;
const int hours_to_minutes = ;
const int mintutes_to_seconds = ;
int days, hours, minutes, seconds,init_times;
cout << "Enter the number of seconds: ";
cin >> init_times;
cin.get();
days = init_times / mintutes_to_seconds / hours_to_minutes / days_to_hours;
hours = init_times / mintutes_to_seconds / hours_to_minutes % days_to_hours;
minutes = init_times / mintutes_to_seconds % hours_to_minutes;
seconds = init_times % mintutes_to_seconds;
cout << init_times << " seconds = " << days << " days," << hours << " hours," << minutes << " minutes," << seconds << " seconds.";
cin.get();
}

3.7.5

#include<iostream>
int main() {
using namespace std;
long long world_num;
long long us_num;
cout << "Enter the world's population: ";
cin >> world_num;
cout << "Enter the population of the US: ";
cin >> us_num;
cin.get();
cout << "The population of the US is " << double(us_num) / double(world_num)* << "% of the world population";
cin.get();
}

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

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

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

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

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

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

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

  4. CSAPP深入理解计算机系统(第二版)第三章家庭作业答案

    <深入理解计算机系统(第二版)>CSAPP 第三章 家庭作业 这一章介绍了AT&T的汇编指令 比较重要 本人完成了<深入理解计算机系统(第二版)>(以下简称CSAPP) ...

  5. C++第三章课后作业答案及解析---指针的使用

    今天继续完成上周没有完成的习题---C++第三章课后作业,本章题涉及指针的使用,有指向对象的指针做函数参数,对象的引用以及友元类的使用方法等 它们具体的使用方法在下面的题目中会有具体的解析(解析标注在 ...

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

    #include<iostream> using namespace std; int main() { ; int shen_gao; cout <<"Please ...

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

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

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

    2.7.1 #include<iostream> int main() { using namespace std; ]; ]; cout << "input nam ...

  9. C++primer第三章标准库类型

    除第二章介绍的基本数据类型外,C++ 还定义了一个内容丰富的抽象数据类型标准库. 本章将介绍标准库中的 vector.string 和 bitset 类型. string 类型支持长度可变的字符串 v ...

随机推荐

  1. postgrSQL 错误ERROR: permission denied

    赋权限: GRANT ALL PRIVILEGES ON TABLE 表名 TO 用户;

  2. Android studio 相关下载

    Android studio  http://www.androiddevtools.cn/ Oracle的VirtulBox https://www.virtualbox.org/wiki/Down ...

  3. CoreThink主题开发(八)使用H-ui开发博客主题之用户登录之前及登录之后

    感谢H-ui.感谢CoreThink! 效果图: 登录之后 登录窗体 想做登录之后的下拉菜单的,实在做不出来了,就一般显示了... 整个面包屑导航这里,先遍历模块,并且是允许前台显示的模块,之后就是判 ...

  4. Python进阶(5)_进程与线程之协程、I/O模型

    三.协程 3.1协程概念 协程:又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存 ...

  5. Loadrunder脚本篇——webservice接口测试(二)

    1.选择协议--Web Service,如下图 2.导入服务 入口1:点击Manage Services ->弹出窗中选择“Import” ->弹出窗中选择“URL”,填写wsdl地址,导 ...

  6. 每天一个Linux命令(53)service命令

        service命令用于对系统服务进行管理.   (1)用法:     用法:  service  [服务]  [操作]   (2)功能:     功能:  service命令用于启动.停止.重 ...

  7. 80211n标准建链速率计算

    转:https://wenku.baidu.com/view/93f99dd3ad51f01dc281f1af.html 转:http://www.docin.com/p-1851128644.htm ...

  8. SOA 面向服务架构 阅读笔记(三)

    7 SOA的主要组件 7.1企业服务总线ESB ESB负责SOA组件之间的互相通信;SOA注册中心的资源库包含表示SOA组件的位置的重要的引用信息: 业务流程编排管理器提供人与人,人与流程,以及流程的 ...

  9. Threalocal的使用及其原理

    虽然现在可以说很多程序员会用ThreadLocal,但是我相信大多数程序员还不知道ThreadLocal,而使用ThreadLocal的程序员大多只是知道其然而不知其所以然,因此,使用ThreadLo ...

  10. 《机器学习基石》第一周 —— When Can Machine Learn?

    (注:由于之前进行了吴恩达机器学习课程的学习,其中有部分内容与机器学习基石的内容重叠,所以以下该系列的笔记只记录新的知识) <机器学习基石>课程围绕着下面这四个问题而展开: 主要内容: 一 ...