#include <iostream>
#include <climits>
using namespace std;
void eg1();
void eg2();
int main()
{
//.eg1();
eg2();
}
void eg1()
{
const float h = 14;
float in;
cout << "请输入您的身高:___\b\b\b";
cin >> in;
cout << "\n您的身高是:" << in*h << " 英尺" <<endl;
}
void eg2()
{
const int yc = 14;//1英尺=14英寸
const double m = 0.0254;//1英寸=0.0254米
const double bang = 2.2;//1kg = 2.2磅
double y, c, z;//y:英尺,c英寸,z磅体重
cout << "请输入您的身高,英尺:___\b\b\b";
cin >> y;
cin.get();
cout <<"英寸:___\b\b\b";
cin >> c ;
cin.get();
cout << "体重:___\b\b\b";
cin >> z;
cin.get();
cout << "按任意键查看结果:"<<endl;
cin.get();
double tz = z/bang;//磅转千克
double sg = (y/yc + c) * m;//英寸转米
double BMI = tz/(sg*sg);
cout << "\nBMI值:"<<BMI<<endl;
}
void eg3()
{
const int d2f = 60;//度转分
const int f2m = 60;//分转秒
double degress, minutes, seconds;
cout << "Enter a latitude in degress, minutes, and seconds:"<<endl;
cout << "First, enter the minutes of arc:";
cin >> degress;
cin.get();
cout << "Next, enter the minutes of arc:";
cin >> minutes;
cin.get();
cout << "Finally, enter the seconds of arc:";
cin >> seconds;
cin.get();
double result = degress + minutes/d2f + seconds/(d2f*f2m);
cout << degress <<" degress, "<<minutes<<" minutes, "<<seconds<<" seconds = "<< result <<" degress"<<endl;
}