有时,我们需要输出确定小数位数的double,可以先引入如下头文件:

#include <iomanip>

 

  然后通过下列方式输出:

  double zzz = 8.66666;
  cout << fixed << setprecision(2) << zzz << endl;

  

  或者:

   if ((aid % (int(allTime / deltaT) / files)) == 0) {
            cout << fixed << setprecision(0) << double(curTime / allTime) * 100 << "% has been calculated..." << endl;
   }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案