5.编写一个程序,要求用户输入全球当前的人口和美国当前的人口(或其他国家的人口)。将这些信息存储在 longlong 变量中,并让程序显示美国(或其他国家)的人口占全球人口的百分比。该程序的输出应与下面类似:
Enter the world’s population:6898758899
Enter the population of the Us:310783781
The population of the Us is 4.50492% of the world population.
#pragma region 第三章练习5
/*
5.编写一个程序,要求用户输入全球当前的人口和美国当前的人口(或其他国家的人口)。
将这些信息存储在 longlong 变量中,并让程序显示美国(或其他国家)的人口占全球人口的百分比。
该程序的输出应与下面类似:
Enter the world's population:6898758899
Enter the population of the Us : 310783781
The population of the Us is 4.50492% of the world population.
*/
#if 1
#include <iostream>
float CalStoDHMS(long long worldPopulation, long long usaPopulation);
int main()
{
using namespace std;
cout << "Enter the world's population:";
long long worldpop,usapop;
cin >> worldpop;
cout << "Enter the population of the Us:";
cin >> usapop;
cout << "The population of the Us is " << CalStoDHMS(worldpop,usapop) << "% of the world population." << endl;
return 0;
}
float CalStoDHMS(long long worldPopulation,long long usaPopulation)
{
return float((double)usaPopulation / (double)(worldPopulation+usaPopulation));
}
#endif
2189

被折叠的 条评论
为什么被折叠?



