C++ Primer Plus第6版—第3章课后习题答案
2019-01-13 12:42
375 查看
[code]//第1题 #include<iostream> int main() { using namespace std; int n_,m; const int c= 12; cout << "输入自己身高:"; cin >> n_; m = n_ * c; cout << m << endl; return 0; }
[code]//第2题 #include<iostream> #include<cmath> int main() { using namespace std; float a, b, c, d, e, f; const int m = 12; const float n = 0.0254; const float p = 2.2; cout << "输入英尺:"; cin >> a; cout << "\n输入英寸:"; cin >> b; cout << "\n输入体重:"; cin >> c; d = c*p; e = pow((a*m+b)*n, 2); f = d / e; cout << f << endl; return 0; }
[code]//第3题 #include<iostream> #include<cmath> int main() { using namespace std; double d, m, s,n; cout << "Enter a latitude in degrees,minutes,and seconds:"; cout << "First,enter the degrees:"; cin >> d; cout << "Next,enter the minutes of arc:"; cin >> m; cout << "Finally,enter the seconds of arc:"; cin >> s; n = d + (m * 60 + s) / 3600; cout << d << " degrees," << m << " minutes," << s << " seconds=" << n << " degrees" << endl; return 0; }
[code]//第4题 #include<iostream> #include<cmath> int main() { using namespace std; int d,h,m,n,s; const int a = 24; const int b = 60; const int c = 60; cout << "Enter the number of seconds:"; cin >> n; d = n / (a*b*c); h = (n - d*a*b*c) / (b*c); m = (n - d*a*b*c - h*b*c)/b; s = n - d * a*b*c - h * b*c - m * b; cout <<n << " seconds=" << d << " days," << h << " hours," << m << " minutes," <<s<<" seconds"<< endl; return 0; }
[code]//第5题 #include<iostream> #include<cmath> int main() { using namespace std; double w, u, p; cout << "Enter the world's population:"; cin >> w; cout << "Enter the population of the US:"; cin >> u; p = (u / w)*100; cout << "The population of the US is " << p << "% of the world population." << endl; return 0; }
[code]//第6题 #include<iostream> #include<cmath> int main() { using namespace std; double a, b, c; cout << "输入驱车里程(英里):"; cin >> a; cout << "使用汽油量(加仑):"; cin >> b; c = a/b; cout << "汽车耗油量为一加仑里程即" << c <<endl; return 0; }
[code]//第7题 #include<iostream> #include<cmath> int main() { using namespace std; double l,z; float a = 62.14; float b = 3.875; cout << "输入每100公里消耗的汽油量(升):"; cin >> l; z = a * b / l; cout << "每加仑" << z <<"英里"<<endl; return 0; }
相关文章推荐
- C++ Primer Plus (第6版)课后习题答案 第二章
- C++ primer plus 第十章课后习题,原创答案。
- C++Primer Plus笔记——第二章 开始学习C++及课后习题答案
- C++Primer Plus笔记——第四章 复合类型及课后习题答案
- C++Primer Plus笔记——第三章 处理数据及课后习题答案
- C++ primer plus 第六版 课后答案 8.6
- C++primer plus第六版课后编程题答案16.9
- C++primer plus第六版课后编程题答案17.1
- C++ Primer Plus(第6版)Chapter 6 编程题答案
- C++primer plus第六版课后编程题答案 6.7
- C++ Primer Plus 第六版 每天总结一章加课后习题
- C++primer plus第六版课后编程题答案9.4
- 【8.3】c++ primer plus 课后编程答案
- c++ primer plus(第6版)中文版 第十三章编程练习答案
- 【7.10】c++ primer plus 课后编程答案
- C++primer plus第六版课后编程练习答案3.5
- C++primer plus第六版课后编程练习答案4.7
- C++primer plus第六版课后编程练习答案5.5
- C++primer plus第六版课后编程练习答案6.6
- C++primer plus第六版课后编程题答案11.3