我有一个计算人口增长的计划.它似乎有效,但是当人口超过100万时,输出的十进制数增加到10的幂.(这被称为科学符号吗?指数形式?我忘了.)
无论如何输出数据作为完整数字?这是输出的代码,我将不得不转换它.
#include "header.h"
void output (float currentPopulation, float years, float birthRate, float deathRate)
{
cout << "the populaion in " << years << " years will be: " << estimatedPopulation (currentPopulation, years, birthRate, deathRate) << endl;
}
Run Code Online (Sandbox Code Playgroud)
新代码:
#include "header.h"
void output (float currentPopulation, float years, float birthRate, float deathRate)
{
cout << "the populaion in " << years << " years will be: " << fixed << setprecision(0) << estimatedPopulation (currentPopulation, years, birthRate, deathRate) << endl;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4645 次 |
| 最近记录: |