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

#include<iostream>
using namespace std; int main()
{
const int unit=;
int shen_gao;
cout <<"Please enter your leight in inches:____\b\b\b";
cin >> shen_gao;
cout << "It is contains: " << shen_gao / unit << " feet" << ", " << shen_gao % unit << " inches.";
cin.get();
cin.get(); return ;
}

#include<iostream>
using namespace std; const int F_1 = ;
const double F_2 = 0.0254;
const double F_3 = 2.2; int main()
{
int feet;
int inch;
double pound;
double BMI; cout << "What's your heights?" << endl;
cout << "Please enter your heights in feet: ";
cin >> feet;
cout << "Please enter your heights in inch: ";
cin >> inch;
cout << endl << "What's your pound?" << endl << "Please enter your pound: ";
cin >> pound;
BMI = (pound/F_3)/((inch+feet* F_1)*F_2);
cout << endl << "Your BMI is " << BMI*BMI << "."; cin.get();
cin.get();
return ;
}

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

#include<iostream>
using namespace std; const int day_hour = ;
const int hour_min = ;
const int min_sec = ; int main()
{
int day;
int hour;
int min;
int sec;
long second;
cout << "Enter the number of seconds: ";
cin >> second; day = second / min_sec / hour_min / day_hour;
hour = second / min_sec / hour_min % day_hour;
min = second / min_sec % hour_min;
sec = second % min_sec;
cout << second << " seconds = " << day << " days, " << hour << " hours, " << min << " minutes, " << sec << " seconds."; cin.get();
cin.get();
return ; }

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

#include<iostream>
using namespace std; int main()
{
double miles, gallons, kilometers, liter;
int flage; cout << "You have two forms of fuel consumption: " << endl
<< "1- the mile of per gallons" << endl
<< "2- the liter of one hundred kilometer" << endl
<< "Plesase chioce(enter 1 or 2): ";
cin >> flage;
if (flage == )
{
cout << "Please enter the distance(mile): ";
cin >> miles;
cout << "Please enter the gasoline amount(gallon): ";
cin >> gallons;
cout << "Wasting a gallon gasoline run " << miles / gallons << " miles." << endl;
}
else {
cout << "Please enter the distance(kilometer):";
cin >> kilometers;
cout << "Please enter the gasoline amount(liter):";
cin >> liter;
cout << "Wasting gasoline per hundred kilometers is " << liter / kilometers * << " liters." << endl;
}
cin.get();
cin.get();
return ;
}

#include<iostream>
using namespace std;
const float One_H_Kilometer_mile = 62.14;
const float Gallon_liter = 3.875; int main()
{
float european_style;
float america_style;
cout << "Please enter European style fuel consumption: ";
cin >> european_style;
america_style = One_H_Kilometer_mile * Gallon_liter / european_style;
cout << european_style << "/100 km = " << america_style << " mpg";
cin.get();
cin.get();
return ;
}
c++ primer plus 第三章 课后题答案的更多相关文章
- c++ primer plus 第七章 课后题答案
#include <iostream> using namespace std; double HAR_AVG(double, double); void TEST(bool); int ...
- c++ primer plus 第六章 课后题答案
#include <iostream> #include <cctype> using namespace std; int main() { char in_put; do ...
- c++ primer plus 第五章 课后题答案
#include <iostream> using namespace std; int main() { ; cout << "Please enter two n ...
- c++ primer plus 第四章 课后题答案
#include<iostream> #include<string> using namespace std; int main() { string first_name; ...
- C++第三章课后作业答案及解析---指针的使用
今天继续完成上周没有完成的习题---C++第三章课后作业,本章题涉及指针的使用,有指向对象的指针做函数参数,对象的引用以及友元类的使用方法等 它们具体的使用方法在下面的题目中会有具体的解析(解析标注在 ...
- c++ primer plus 第二章 课后题答案
#include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...
- python核心编程第5章课后题答案
5-8Geometry import math def sqcube(): s = float(raw_input('enter length of one side: ')) print 'the ...
- python核心编程第4章课后题答案(第二版75页)
4-1Python objects All Python objects have three attributes:type,ID,and value. All are readonly with ...
- python核心编程第3章课后题答案(第二版55页)
3-4Statements Ues ; 3-5Statements Use\(unless part of a comma-separated sequence in which case \ is ...
随机推荐
- Python qq企业邮箱发送邮件
Python qq企业邮箱发送邮件 进入客户端设置: 下面是代码部分: from email.header import Header from email.mime.text import MIME ...
- css 文本超出容器长度后自动省略的方法!
我们在给用户显示文本内容的时候,往往需要避免文本内容超出容器宽度,防止换行溢出,小弟在网上找了下发现网上的实现仅仅只是实现了用 ...省略了的功能! 而并没有获取光标提示的功能,所有小弟就结合网上的代 ...
- 使用PowerMockito 对静态类进行mock
Mock的中文的意思就是模拟,Mockito是mock的扩展,但是Mockito并不支持对静态类的mock,所以我们引入PowerMockito实现对静态类的mock. 首先pom添加PowerMoc ...
- 植物大战僵尸作弊器源代码(MFC版)
控制版使用不太方便,此MFC版与控制台版内容一样.具体可以参考前面.此处只附源代码,不加以说明.......... 头文件 // jsMFCDlg.h : 头文件 // #pragma once // ...
- 2016-2017-2 《Java程序设计》第5周学习总结
学号 2016-2017-2 <Java程序设计>第5周学习总结 教材部分学习内容总结 第八章: 一.语法与继承架构 使用try.catch: •执行流程 1.尝试执行try区块中程序代码 ...
- Mysql优化_内置profiling性能分析工具
如果要进行SQL的调优优化和排查,第一步是先让故障重现,但是这个并不是这一分钟有问题,下一秒就OK.一般的企业一般是DBA数据库工程师从监控里找到问题.DBA会告诉我们让我们来排查问题,那么可能很多种 ...
- P3435 [POI2006]OKR-Periods of Words
P3435 [POI2006]OKR-Periods of Words 题解传送门 kmp 注意:由于题目说只要A满足是2Q的前缀,所以求的不是严格的最大循环子串(20pts) 我们需要求出的是在主串 ...
- JavaScript DOM 元素属性 状态属性
JavaScript DOM 元素属性 状态属性 版权声明:未经允许,严禁转载! 元素的属性 核心 DOM 为我们提供了操作元素标准属性的统一 API. 所有属性节点都储存在元素的 attribute ...
- assert_param
在STM32的固件库和提供的例程中,到处都可以见到assert_param()的使用.如果打开任何一个例程中的stm32f10x_conf.h文件,就可以看到实际上assert_param是一个宏定义 ...
- SQL语句 查询同一个字符在某一个字符串中出现的次数
select len(replace(字段名A,';','--'))-len(字段名A) from table表名