#include <iostream>
#include <iomanip>

int main() {
    double num;
    std::cin >> num;
    
    std::cout << std::fixed << std::setprecision(6) << num << std::endl; // %f
    std::cout << std::fixed << std::setprecision(5) << num << std::endl; // %f with 5 decimal places
    std::cout << std::scientific << std::setprecision(6) << num << std::endl; // %e
    std::cout << std::setprecision(6) << num << std::endl; // %g
    
    return 0;
}
C++ 浮点数格式化输出 - 使用 printf 风格格式符

原文地址: https://www.cveoy.top/t/topic/uNy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录