方法一(也是常用方法):

#include <cstdio> // C++程序中调用标准C的输入输出库

using namespace std;
int main()
{   
double d;   d = 1.65469464;   printf("%lf",d); // 保留默认的小数位(好像是6位)   printf("%.3lf",d); // 指定保留三位小数
  return 0; }

 

方法二:

#include<iomanip>

using namespace std;

int main()
{
  double d;
  d = 1.65469464;
  cout<<setprecision(3)<<std::fixed<<你的数据; // 指定保留三位小数
  return 0; 
}

 

相关文章:

  • 2021-07-29
  • 2021-09-05
  • 2022-12-23
  • 2021-11-27
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案