1.
#include <iostream>
int main()
{
using namespace std;
const int CHANGE = 12;
int h = 0;
int feet = 0;
int inch = 0;
cout << "Please enter your height(Inches):___\b\b\b";
cin >> h;
feet = h / CHANGE;
inch = h % CHANGE;
cout << "Your height is " << feet << " feet " << inch << " inches."<< endl;
return 0;
}
#include <iostream>
#include <cmath>
int main()
{
using namespace std;
const int CHANGE_INCH = 12;
const double CHANGE_M = 0.0254;
const double CHANGE_P = 2.2;
int feet = 0;
int inch = 0;
double pound = 0;
double bmi = 0;
cout << "请以几英尺几英寸的方式输入您的身高。" << endl;
cout << "请输入英尺的值:";
cin >> feet;
cout << "请输入英寸的值:";
cin >> inch;
cout << "请输入您的体重(磅):";
cin >> pound;
bmi = pound / CHANGE_P / pow((feet * CHANGE_INCH + inch) * CHANGE_M, 2);
cout << "您的BMI为 " << bmi << endl;
return 0;
}
#include <iostream>
int main()
{
using namespace std;
const int CHANGE = 60;
double degree = 0.0;
double minute = 0.0;
double second = 0.0;
double degrees = 0.0;
cout << "Enter a latitude in degrees, minutes, and seconds:" << endl;
cout << "First, enter the degrees:";
cin >> degree;
cout << "Next, enter the minutes of arc:";
cin >> minute;
cout << "Finally, enter the seconds of arc:";
cin >> second;
degrees = degree + (minute + second / CHANGE) / CHANGE;
cout << degree << " degrees, " << minute << " minutes, " << second << " seconds = " << degrees << " degrees" << endl;
return 0;
}
#include <iostream>
int main()
{
using namespace std;
const int CHANGE_D = 24;
const int CHANGE_H = 60;
const int CHANGE_M = 60;
long seconds = 0;
int day = 0;
int hour = 0;
int minute = 0;
int second = 0;
cout << "Enter the number of seconds: ";
cin >> seconds;
second = seconds % CHANGE_M;
minute = seconds / CHANGE_M % CHANGE_H;
hour = seconds / CHANGE_M / CHANGE_H % CHANGE_D;
day = seconds / CHANGE_M / CHANGE_H / CHANGE_D;
cout << seconds << " seconds = " << day << " days, " << hour << " hours, " << minute << " minutes, " << second << " seconds" << endl;
return 0;
}
#include <iostream>
int main()
{
using namespace std;
double m = 0.0;
double g = 0.0;
double km = 0.0;
double l = 0.0;
while (true)
{
cout << "请输入驱车里程(英里):";
cin >> m;
if (m <= 0) break;
cout << "请输入使用汽油量(加仑):";
cin >> g;
if (g <= 0) break;
cout << "汽车耗油量为一加仑的里程为 " << m / g << " 英里。" << endl;
break;
}
while (true)
{
cout << "请输入驱车里程(公里):";
cin >> km;
if (km <= 0) break;
cout << "请输入使用汽油量(升):";
cin >> l;
if (l <= 0) break;
cout << "汽车每100公里的耗油量为 " << l / km * 100 << " 升。" << endl;
break;
}
return 0;
}
#include <iostream>
int main()
{
using namespace std;
double europe = 0.0;
double us = 0.0;
cout << "请按欧洲风格输入汽车的耗油量(每100公里消耗的汽油量(升)):";
cin >> europe;
us = 62.14 / (europe / 3.875);
cout << "美国风格的耗油量为:每加仑 " << us << " 英里。" << endl;
return 0;
}