c++ primer plus 第六版第三章编程练习答案
来源:互联网 发布:淘宝运营公司靠谱吗 编辑:程序博客网 时间:2024/04/30 14:03
3.7.1
#include <iostream>
#include <cstdlib>
int main()
{
using namespace std;
//一米八是71英寸,foot 英尺,inch英寸
int foot, inch;
cout << "Enter your height(inch):__\b\b";
cin >> inch;
foot = inch / 12;
inch = inch % 12;
cout << "Your height is " << foot << " foot " << inch << " inch " << endl;
system("pause");
return 0;
}
3.7.2
#include <iostream>
#include <cstdlib>
int main()
{
using namespace std;
//一米八是五英尺十一英寸,75kg是165磅
int foot, inch;
float meter, pound, kilogram;
cout << "Input your foot and inch:";
cin >> foot;
cin >> inch;
cout << "Input your pound:";
cin >> pound;
meter = 0.3048*foot + (inch*1.0 / 12)*0.3048;
kilogram = pound / 2.2;
cout << "The BMI of me is " << kilogram / (meter * meter);
system("pause");
return 0;
}
3.7.3
#include <iostream>
#include <cstdlib>
int main()
{
using namespace std;
const double change = 60.0; //度分秒之间的进位为60
double degrees, minute, seconds;
cout << "Enter a latitude in degrees, minutes, and seconds: " << endl;
cout << "First, enter the degrees: ";
cin >> degrees;
cout << "Next, enter the minytes of arc: ";
cin >> minute;
cout << "Finally, enter the seconds of arc: ";
cin >> seconds;
cout << degrees << " degrees, "
<< minute << " minute, "
<< seconds << " seconds = ";
degrees = degrees + (minute) / change + (seconds) / (change * change);
cout << degrees << " degrees" << endl;
system("pause");
return 0;
}
3.7.4
#include <iostream>
#include <cstdlib>
int main()
{
using namespace std;
const float S_P_M = 60.0; //seconds per minute
const float M_P_H = 60.0; //minutes per hour
const float H_P_D = 24.0; //hours per day
int day, hour, minute, second;
cout << "Enter the number of seconds:";
cin >> second;
day = second / (S_P_M*M_P_H*H_P_D);
hour = (second - day*S_P_M*M_P_H*H_P_D) *1.0 / (S_P_M*M_P_H);
minute = (second - day*S_P_M*M_P_H*H_P_D - hour * S_P_M*M_P_H) / S_P_M;
cout << second << " seconds = ";
second = (second - day*S_P_M*M_P_H*H_P_D - hour * S_P_M*M_P_H - minute * S_P_M);
cout << day << " days, "
<< hour << " hours, "
<< minute << " minutes, "
<< second << " seconds" << endl;
system("pause");
return 0;
}
3.7.5
#include <iostream>
#include <cstdlib>
int main()
{
using namespace std;
long long population, US;
cout << "Enter the world's population :";
cin >> population;
cout << "Enter the population of the US:";
cin >> US;
cout << "The population of the US is "
<< US * 100.0 / population
<< "%"
<< "of the world population."
<< endl;
system("pause");
return 0;
}
3.7.6
#include <iostream>
#include <cstdlib>
const double KM100_TO_MILES = 62.14;
const double LITERS_PER_GALLON = 3.875;
int main(void)
{
using namespace std;
double euro_rating;
double us_rating;
cout << "Enter fuel consumption in liters per 100 km: ";
cin >> euro_rating;
us_rating = (LITERS_PER_GALLON * KM100_TO_MILES) / euro_rating;
cout << euro_rating << " liters per 100 km is ";
cout << us_rating << " miles per gallon.\n";
system("pause");
return 0;
}
- C ++ Primer Plus 第六版 第六章编程练习答案
- C++ Primer Plus第六版 第三章 编程练习答案
- c++ primer plus 第六版第三章编程练习答案
- c++.primer.plus第五版第六章编程练习答案
- C ++ Primer Plus 第六版 第七章编程练习答案
- C ++ Primer Plus 第六版 第八章编程练习答案
- C ++ Primer Plus 第六版 第九章编程练习答案
- C ++ Primer Plus 第六版 第十章编程练习答案
- C ++ Primer Plus 第六版 第十一章编程练习答案
- C ++ Primer Plus 第六版 第十二章编程练习答案
- C ++ Primer Plus 第六版 第十三章编程练习答案
- C ++ Primer Plus 第六版 第十七章编程练习答案
- C Primer Plus (第五版) 第六章 编程练习 答案
- C++ Primer Plus第六版 第六章 编程练习答案
- C++primer plus第六版课后编程练习答案2.2
- C++primer plus第六版课后编程练习答案2.3
- C++primer plus第六版课后编程练习答案2.4
- C++primer plus第六版课后编程练习答案2.5
- Gradle DSL method not found: 'runProguard()'
- codeforces 167B Wizards and Huge Prize (概率dp,类似背包)
- 【屌丝程序的口才逆袭演讲稿50篇】第八篇:坚持的力量 【张振华.Jack】
- 网络流之最大流(Edmonds-Karp算法和Dinic算法)
- 将手指滑出的矩形区域保存到图像视图(UIImageView)中(UItouch 触控事件)
- c++ primer plus 第六版第三章编程练习答案
- 管理经济学学习之初探
- MySQL添加用户、删除用户与授权(测试可用),忘记密码
- C#WPF 语音开发教程 TTS中英文语音(男女声音)朗读 源代码下载 csdn tts(text to sound) 一步一步 教你制作语音软件 附图和源代码
- SurfaceView实现模拟时钟
- iOS开发-修改状态栏文字颜色
- 第15天:hive表操作 内部表和外部表的创建、修改、删除操作实战
- 在iOS7中修改状态栏字体的颜色
- (二十六)静态单元格(Cell)