1.
#include <iostream>
int main() {
using namespace std;
const float Convert_in = 2.54;
const int Convert_foot = 12;
int high = 0;
int inch = 0;
int foot = 0;
cout << "请输入您的身高(cm):____\b\b\b\b";
cin >> high;
inch = high / Convert_in;
foot = inch / Convert_foot;
inch = inch % Convert_foot;
cout << "您的身高转换结果为: " << foot << " 英尺 " << inch << " 英寸" << endl;
return 0;
}
2.
#include <iostream>
int main() {
using namespace std;
const float Convert_in = 2.54;
const int Convert_foot = 12;
const float Convert_pound = 2.2;
int high_foot = 0;
int high_inch = 0;
float high_metre = 0.0;
float weight = 0.0;
float bml = 0.0;
cout << "请输入您的身高英尺数部分(foot):____\b\b\b\b";
cin >> high_foot;
cout << endl;
cout << "请输入您的身高英寸数部分(inch):____\b\b\b\b";
cin >> high_inch;
cout << endl;
cout << "请输入您的体重的磅数(pound):____\b\b\b\b";
cin >> weight;
cout << endl;
high_metre = (((high_foot * Convert_foot) + high_inch) * Convert_in) / 100;
weight = weight / Convert_pound;
bml = weight / (high_metre * high_metre);
cout << "您的BML指数为: " << bml << endl;
if (bml < 18.5 || bml > 23.9) {
cout << "您的BML指数不在正常范围内";
}
else {
cout << "您的BML指数正常";
}
return 0;
}
3.
#include <iostream>
int main() {
using namespace std;
const int Convert_m = 60;
const int Convert_s = 60;
float degrees = 0;
float minutes = 0;
float seconds = 0;
cout << "Enter a latitude in degree, minutes, and seconds: ";
cin >> degrees >> minutes >> seconds;
cout << endl;
cout << "First, enter the degrees: " << degrees << endl;
cout << "Next, enter the minutes of arc: " << minutes << endl;;
cout << "Finally, enter the seconds of arc: " << seconds << endl;;
float degrees_conv = 0.0;
degrees_conv = degrees + (minutes / Convert_m) + ((seconds / Convert_s) / Convert_m);
cout << degrees << " degrees, " << minutes << " minutes, "
<< seconds << " seconds " << "= " << degrees_conv << " degrees";
return 0;
}
4.
#include <iostream>
int main() {
using namespace std;
const int OneDayTime = 24;
const int OneHourTime = 60;
const int OneMinuteTime = 60;
long long seconds = 0;
long long seconds_temp = 0;
int inDays = 0;
int inMinutes = 0;
int inHours = 0;
int inSeconds = 0;
cout << "Enter the number of seconds: ";
cin >> seconds;
seconds_temp = seconds;
inDays = seconds_temp / (OneMinuteTime * OneHourTime * OneDayTime);
seconds_temp -= static_cast<long long>(inDays) * (OneMinuteTime * OneHourTime * OneDayTime);
inHours = seconds_temp / (OneMinuteTime * OneHourTime);
seconds_temp -= static_cast<long long>(inHours) * (OneMinuteTime * OneHourTime);
inMinutes = seconds_temp / OneMinuteTime;
inSeconds = seconds % OneMinuteTime;
cout << seconds << " seconds " << " = " << inDays << " days, "
<< inHours << " hours, " << inMinutes << " minutes, "
<< inSeconds << "seconds.";
return 0;
}
5.
#include <iostream>
int main() {
using namespace std;
long long ChinaPopulation = 0;
long long allPopulation = 0;
float per = 0.0;
cout << "请输入世界人口总数: ";
cin >> allPopulation;
cout << "请输入中国目前总人口数量: ";
cin >> ChinaPopulation;
per = static_cast<long double>(ChinaPopulation) / allPopulation;
cout << "中国人口占世界人口的百分比为: " << per * 100 << "% " << "of the world population.";
return 0;
}
6.
#include <iostream>
int main() {
using namespace std;
float dis = 0.0;
float oilVolume = 0.0;
float result = 0.0;
cout << "请输入您的驱车里程(km): ";
cin >> dis;
cout << "请输入您使用的汽油量(L): ";
cin >> oilVolume;
result = oilVolume / (dis / 100);
cout << "每100公里的耗油量(升): " << result << "(L/100km)";
return 0;
}
7.
#include <iostream>
int main() {
using namespace std;
float dis = 0.0;
float oilVolume = 0.0;
float result1 = 0.0;
float result2 = 0.0;
cout << "请输入您的驱车里程(km): ";
cin >> dis;
cout << "请输入您使用的汽油量(L): ";
cin >> oilVolume;
result1 = oilVolume / (dis / 100);
result2 = dis / oilVolume;
cout << "(欧洲风格)" << "每100公里的耗油量: " << result1 << "(L/100km)";
cout << "(美国风格)" << "每升燃油行驶公里数: " << result2 << "(km/L)";
return 0;
}