#include <iostream>
#include <iomanip>//需要添加此头文件
using namespace std;
int main()
{
    float a=0.20001;
    float b=2;
    cout<<setprecision(2)<<a<<endl;//输出小数点后两位,0会舍去
    cout.setf(ios::fixed);
    cout<<fixed<<setprecision(2)<<b<<endl;//补零
    return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-10-06
猜你喜欢
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案