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 ...
随机推荐
- 7.8 Models -- The Rest Adapter
一.概述 默认的,store将会使用 DS.RESTAdapter来加载和存储records.这个RESTAdapter假定URLS和JSON关联每一个model是约定好的:这意味着,如果你遵循这个规 ...
- sql2008评估板过期
1.查看sql2008到期时间,打开数据库---帮助---关于,具体可查看试用期还有多长时间 2.重新激活 : ① 打开注册表后,找到并把 HKEY_LOCAL_MACHINE\SOFTWARE\Mi ...
- Django初级手册1-项目和应用的创建与简单的数据库操作
创建项目 django-admin.py startproject mysite 1. 目录结构 mysite/ #项目的名称 manage.py #可通过命令和项目进行交互的文件 mysite/ # ...
- Object-C-NSArray
NSArray *fruitArray=[[NSArray alloc] initWithObjects:@"apple",@"banana",@"p ...
- 2018-2019-2 20165209 《网络对抗技术》Exp5:MSF基础应用
2018-2019-2 20165209 <网络对抗技术>Exp5:MSF基础应用 目录 一.基础问题回答和实验内容 二.攻击实例 主动攻击的实践 ms08_067 payload/gen ...
- iphone6 inline-flex兼容问题
在编写微信端页面时,遇到这样的问题:position属性为flex的导航栏,其li标签在其余设备上显示正常,但在iphone6上浮动错误. 究其原因,是iphone6不支持position属性中的fl ...
- SDOI2019Round1游记
SDOI2019Round1游记 Day 0 报道日,早晨五点睡的觉,一觉醒来已经一点半了,收拾收拾东西报道去了.因为没吃饭,坐着出租车晕车了,我让师傅把我放到历下大润发,我去金拱门吃了点饭才去的23 ...
- Javascript 判断对象是否相等
在Javascript中相等运算包括"==","==="全等,两者不同之处,不必多数,本篇文章我们将来讲述如何判断两个对象是否相等? 你可能会认为,如果两个对象 ...
- CentOS7防火墙之firewalld
今天在centos7上装mysql8,装好了之后发现主机的navicat始终连不上centos中的mysql 搜索发现是防火墙的问题,已查看iptables,嗯?没有了这个防火墙,原来centos换防 ...
- 微信小程序编写新闻阅读列表
微信小程序编写新闻阅读列表 不忘初心,方得始终:初心易得,始终难守. 本篇学习主要内容 Swiper 组件(轮播图) App.json 里的关于导航栏.标题的配置. Page 页面与应用程序的生命周期 ...