C++ Primer Plus 第六版(中文版)课后编程题----第三章
来源:互联网 发布:角谷猜想知乎 编辑:程序博客网 时间:2024/06/11 05:35
3.1:
不知道下划线指示输入位置理解是否有误?
#include <iostream>using namespace std;#define c 12int main(){int cun;cout << "你的身高是____英寸?" << endl;cin >> cun;int a, b;a = cun / c;b = cun%c;cout << "你的身高转换之后为 " << a << " 英尺," << b << " 英寸。" << endl;cin.get();cin.get();return 0;}
3.2:
#include <iostream>using namespace std;#define FEETtoINCH 12#define INCHtoMILE 0.0254#define KGtoPOUND 2.2int main(){int feet, inch;float pound, mile, kg, ibm;cout << "请输入你的身高:__英尺__英寸。" << endl;cin >> feet >> inch;cout << "请输入你的体重:__磅。" << endl;cin >> pound;mile = INCHtoMILE*float(feet*FEETtoINCH + inch);kg = pound / KGtoPOUND;ibm = kg / (mile*mile);cout << "你的体重指数为:" << ibm << endl;cin.get();cin.get();return 0;}
3.3
#include <iostream>using namespace std;#define T 60int main(){int degree, second, minute;double degree_d;cout << "Enter a latitude in degrees, minutes and seconds:" << endl<< "First, enter the degrees:";cin >> degree;cout << "Next, enter the minutes of arc:";cin >> minute;cout << "Finally, enter the seconds of arc:";cin >> second;degree_d = double(degree) + double(minute) / T + double(second) / T / T;cout << degree << " degrees, " << minute << " minutes, " << second << " seconds = " << degree_d << " degrees" << endl;cin.get();cin.get();return 0;}
3.4
#include <iostream>using namespace std;#define T 60#define D 24int main(){long long seconds;long long temp;int day, hour, minu, sec;cout << "Enter the number of seconds: ";cin >> seconds;sec = seconds%T;temp = seconds / T;minu = temp%T;temp = temp / T;hour = temp%T;temp = temp / D;day = temp;cout << seconds << " seconds = " << day << " days, " << hour << " hours, " << minu << " minutes, " << sec << " seconds." << endl;cin.get();cin.get();return 0;}
3.5
#include <iostream>using namespace std;int main(){long long Population_USA, Population_world;double ratio;cout << "Enter the world's population: ";cin >> Population_world;cout << "Enter the population of the US: ";cin >> Population_USA;ratio = (double(Population_USA)) / (double(Population_world)) * 100;cout << "The population of the US is " << ratio << "% of the world population." << endl;cin.get();cin.get();return 0;}
3.6
#include <iostream>using namespace std;#define LEN 1.609344//1 英里 = 1.609344 千米#define VOLUME 3.7854118//1 美式加仑 = 3.7854118 升int main(){double mile, gallon;cout << "请输入以英里为单位的里程数:";cin >> mile;cout << "请输入以加仑为单位的汽油量:";cin >> gallon;cout << "美国风格的耗油量为:每加仑 " << (double(mile)) / (double(gallon)) << " 英里。" << endl;cout << "欧洲风格的耗油量为:每 100 公里的耗油量为:" << (double(gallon*VOLUME)) / (double(mile*LEN)) * 100 << "升。" << endl;cin.get();cin.get();return 0;}
3.7
该题中不知是否是我的计算有误,运行结果总是和提供的例子对不上,欢迎指正:
#include <iostream>using namespace std;#define TO (62.14*3.875)int main(){float mpg;cout << "请输入美国风格的耗油量(每加仑多少英里):";cin >> mpg;cout << mpg << "mpg 对应的欧洲风格的耗油量为:" << TO / mpg << "/100km" << endl;cin.get();cin.get();return 0;}
0 0
- C++ Primer Plus 第六版(中文版)课后编程题----第三章
- C++ Primer Plus 第六版(中文版)课后编程题----第六章
- C++ Primer Plus 第六版(中文版)课后编程题----第四章
- C++ Primer Plus 第六版(中文版)课后编程题----第五章
- C++ Primer Plus 第六版(中文版)课后编程题----第七章
- C++ Primer Plus 第六版(中文版)课后编程题----第八章
- C++primer plus第六版课后编程题答案 6.1
- C++primer plus第六版课后编程题答案 6.2
- C++primer plus第六版课后编程题答案 6.3
- C++primer plus第六版课后编程题答案 6.4
- C++primer plus第六版课后编程题答案 6.5
- C++primer plus第六版课后编程题答案 6.6
- C++primer plus第六版课后编程题答案 6.7
- C++primer plus第六版课后编程题答案 6.8
- C++primer plus第六版课后编程题答案 6.9
- C++primer plus第六版课后编程题答案7.1
- C++primer plus第六版课后编程题答案7.2
- C++primer plus第六版课后编程题答案7.3
- Hadoop2.7.1概述
- logm--求矩阵的对数
- apache的安装配置 & Tomcat 安装配置
- Ajax跨域、Json跨域、Socket跨域和Canvas跨域等同源策略限制的解决方法
- Java中RSA非对称密钥加解密使用示例
- C++ Primer Plus 第六版(中文版)课后编程题----第三章
- GDI+ 双缓冲实现和局部刷新技术
- 高斯曲线拟合原理及实现
- ViewController生命周期
- Jsoup 网页抓取数据之获取汽车时刻表 实例解析
- UVA146 ID codes
- 递归解决全排列
- spring boot jsp
- funm--矩阵的函数运算