C ++ Primer Plus Chapter 3授業後のプログラミング演習1-7

1。

#include
int main()
{
using namespace std;
const double inch_foot = 0.0833333;
int myheight_in;
cout << "Please enter your height(inch)______ \ b \ b \ b \ b \ b \ b";
cin >> myheight_in;
cout << "あなたの身長は" << myheight_in * inch_foot << "feet。" << endl;

return 0;

}

#include
int main()
{
名前空間stdを使用;
const int ft_in = 12;
const double in_m = 0.0254;
const double kg_pound = 2.2;
double my_height_ft;
double my_weight_lb;
double my_height_in;
cout <<“请输入你的身高(英尺英寸):”;
cin >> my_height_ft >> my_height_in;
cout << "请输入你的体重(鵺):";
cin >> my_weight_lb;
cout << "你的BMI值是:" <<(my_weight_lb / kg_pound)/
(((my_height_ft * ft_in + my_height_in)* in_m)*
((my_height_ft * ft_in + my_height_in)* in_m))<< endl;

return 0;

}

#include
int main()
{
名前空間stdを使用;
const double Lat_d_m_s = 60.0;
int度、分、秒。
二重度;
cout << "度、分、秒で緯度を入力してください:" << endl;
cout << "最初に、度を入力します:";
cin >>程度;
cout << "次に、分角を入力してください:";
シン>>分;
cout << "最後に、弧の秒を入力します:";
cin >> 2番目;
度=度+分/ Lat_d_m_s +秒/ Lat_d_m_s / Lat_d_m_s;

cout <<degree <<" degrees, "<<minute <<" minutes, "
<<second <<" seconds = " <<degrees <<" degrees " <<endl;
return 0;

}

#include
int main()
{
名前空間stdを使用;
長い秒。
const short hou_min_sec = 60;
const short day_hou = 24;
二重日、時間、分、秒;
cout <<「秒数を入力してください:」;
cin >> seconds;
秒=秒%hou_min_sec;
分=秒/ hou_min_sec%hou_min_sec;
時間=秒/ hou_min_sec / hou_min_sec%day_hou;
日数=秒/ hou_min_sec / hou_min_sec / day_hou;
cout << seconds << "seconds =" << int(days)<< "days、"
<< int(hours)<< "hours、" << int(minute)<< "minutes、"
<< int(秒)<< "秒" << endl;

return 0;

}

#include
int main()
{
名前空間stdを使用;
long long global_pop、usa_pop;
ダブルプロポーション;
cout << "世界の人口を入力してください:";
cin >> global_pop;
cout << "米国の人口を入力してください:";
cin >> usa_pop;
プロポーション= 100.0 * usa_pop / global_pop;
cout << "米国の人口
は、世界の人口の" <<割合<< "%です。" << endl;

return 0;

}

#include
int main()
{
using namespace std;
double total_mil、fuel_con、fuel_con_hun;
cout << "please enter the total mileage(km):";
cin >> total_mil;
cout << "please enter the Fuelsumption (liter): ";
Cin >> fuel_con;
fuel_con_hun = fuel_con / total_mil * 100;
cout <<" 100キロメートルあたりの燃料消費量は、「<< fuel_con_hun <<」リットルです。「<< endl;

return 0;

}

#include
int main()
{
名前空間stdを使用;
const double HunKm_mi = 62.14;
const double UsGal_l = 3.875;

double us_mpg ,hun_km;
cout <<"请输入每100公里的耗油量(升): ";
cin >>hun_km;
us_mpg = HunKm_mi / (hun_km / UsGal_l);

cout <<"100公里耗油量为 " <<hun_km <<"升 = "
<<int (us_mpg) <<" mpg." <<endl;

return 0;

}

オリジナルの記事を85件公開 Like1 Visits1889

おすすめ

転載: blog.csdn.net/Tekkenwxp/article/details/103576766