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

时间:2021-02-07 09:05:12

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 ;
}

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

#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 ;
}

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

#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 ;
}

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

#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 ; }

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

#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 ;
}

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

#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 ;
}

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

#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 第三章 课后题答案的更多相关文章

  1. c&plus;&plus; primer plus 第七章 课后题答案

    #include <iostream> using namespace std; double HAR_AVG(double, double); void TEST(bool); int ...

  2. c&plus;&plus; primer plus 第六章 课后题答案

    #include <iostream> #include <cctype> using namespace std; int main() { char in_put; do ...

  3. c&plus;&plus; primer plus 第五章 课后题答案

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

  4. c&plus;&plus; primer plus 第四章 课后题答案

    #include<iostream> #include<string> using namespace std; int main() { string first_name; ...

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

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

  6. c&plus;&plus; primer plus 第二章 课后题答案

    #include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...

  7. python核心编程第5章课后题答案

    5-8Geometry import math def sqcube(): s = float(raw_input('enter length of one side: ')) print 'the ...

  8. python核心编程第4章课后题答案(第二版75页)

    4-1Python objects All Python objects have three attributes:type,ID,and value. All are readonly with ...

  9. python核心编程第3章课后题答案(第二版55页)

    3-4Statements Ues ; 3-5Statements Use\(unless part of a comma-separated sequence in which case \ is ...

随机推荐

  1. html5 canvas常用api总结&lpar;三&rpar;--图像变换API

    canvas的图像变换api,可以帮助我们更加方便的绘画出一些酷炫的效果,也可以用来制作动画.接下来将总结一下canvas的变换方法,文末有一个例子来更加深刻的了解和利用这几个api. 1.画布旋转a ...

  2. AudioRecord类获取录音音量分贝数

    转自:http://www.jb51.net/article/64806.htm   public class AudioRecordDemo {     private static final S ...

  3. jquery里面的循环的用法

    下面提一下jQuery的each方法的几种常用的用法 Js代码 var arr = [ "one", "two", "three", &qu ...

  4. Oak Seeds 网站项目回顾

    项目是一个教育类网站,先给出网站网址:http://www.oakseeds.cn/ Oak Seeds原本的名字叫做American School,后来更给为Oak Seeds,意为橡木子.网站是为 ...

  5. Nginx的负载均衡 - 保持会话 &lpar;ip&lowbar;hash&rpar;

    Nginx版本:1.9.1 我的博客:http://blog.csdn.net/zhangskd 算法介绍 ip_hash算法的原理很简单,根据请求所属的客户端IP计算得到一个数值,然后把请求发往该数 ...

  6. Python常用模块:datetime

    使用前提: >>> from datetime import datetime 常见用法: 1.获取当前日期和时间 >>> now = datetime.now() ...

  7. Hibernate 映射及查询

    实体类和实体之间的关系:一对多,多对多 数据库设计:e_r 一个实体对象就是一个表格,  如果是1对多的关系,将多方的主键拿到1方做外键.  多对多:重新建立一张新的表格,将双方的主键拿到这里做外键 ...

  8. Myeclipse调试模式下自动提示变量值设置

    1.Window->Preferences->Java->Editor->Hovers 将[Variable Values]选择即可,如果第一个[Combined Hover] ...

  9. linux远程开启不挂起的服务

    解决Linux关闭终端(关闭SSH等)后运行的程序自动停止 λ nohup --help Usage: nohup COMMAND [ARG]... or: nohup OPTION Run COMM ...

  10. 用vs2015 编译 web app ionic

    1.要下载https://git-for-windows.github.io/ 2.下载ionic模版