c++风格的格式化输出


#include <iostream>
#include <iomanip>
int main(int argc, const char *argv[])
{
    double f;
    std::cin >> f;
    std::cout << "c = " << std::setiosflags(std::ios::fixed) << std::setprecision(3) << 5 * (f - 32) / 9 << std::endl;
    return 0;
}

以上为保留三位小数,

原文地址:https://www.cnblogs.com/sunstars/p/4012546.html