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. SSH远程登陆docker容器

    环境: Ubuntu 16.04(mac osx的VMware Fushion环境) 任务: Ubuntu 16.04通过SSH登陆docker(目的是为了运行在其他服务器的Jenkins访问dock ...

  2. random模块(随机数库)

    random random.random random.random()用于生成一个0到1的随机浮点数: 0 <= n < 1.0 random.uniform random.unifor ...

  3. Linux服务器基本信息查看

    Linux服务器基本信息通常包括如下几方面: CPU信息 内存使用信息 硬盘使用情况 服务器负载状况 其它参数 1.获取CPU的详细情况 [root@VM_41_84_centos ~]# cat / ...

  4. myql命令

    ALTER TABLE 表名 DROP COLUMN 列名#删除某一列

  5. VC6.0 开发 64 位程序

    1. 设置平台SDK(如:Microsoft platform sdk 2003),选择64位的编译.链接环境. setenv /XP64 /DEBUG 2. 利用这个环境启动VC6.0. msdev ...

  6. Git版本控制系统VCS

    Git版本控制系统VCS 一.版本控制系统基本情况说明 版本控制是一种记录一个或者若干个文件内容的变化,以便将来查阅特定版本修订情况的系统 1.作用 记录文件的所有历史变化 随时可回复到任何一个历史状 ...

  7. 【HackerRank】Find the Median(Partition找到数组中位数)

    In the Quicksort challenges, you sorted an entire array. Sometimes, you just need specific informati ...

  8. Python编程-架构、Socket

    一.客户端/服务器架构 1.C/S架构 Client/Server架构,即服务器/客户端架构. 客户端和服务器端的程序不同,用户的程序主要在客户端,服务器端主要提供数据管理.数据共享.数据及系统维护和 ...

  9. Sublime Text3 打开文档乱码

    一.安装包管理器使用Ctrl+~快捷键或者通过View->Show Console菜单打开命令行,粘贴如下代码 import urllib.request,os; pf = 'Package C ...

  10. com.android.dex.DexIndexOverflowException: Cannot merge new index 66299 into a non-jumbo instruction

    打包时控制台输出: Error:Execution failed for task ':app:transformClassesWithDexForAll32Release'. > com.an ...