最近在读这本C++经典之经典,把一些课后习题作业发出来给大家参考:
#include <iostream>
using namespace std;
void p_1()
{
int height;
const int c = 12;
cout << "Enter your height(in):"<<endl;
cin >> height;
int ft = height/c;
int in = height%c;
cout <<"Your height is "<< ft <<"ft "<< in <<"in."<<endl;
}
void p_2()
{
int ft,in;
float pounds;
cout << "Enter your height in ft and in:"<<endl;
cin >> ft;
cin >> in;
cout << "Enter your weight in pounds:"<<endl;
cin >> pounds;
float height = (12*ft+in)*0.0254;
float kg = pounds/2.2;
float BMI = kg/(height*height);
cout << "Your BMI is "<<BMI<<endl;
}
void p_3()
{
int degrees,minutes,seconds;
const double c = 60;
cout <<