1 2 3 4 5 6 7 8 9 10 11
#include <iostream> #include <iomanip> int main() { double pi = 3.1415926536; std::cout << std::setprecision(2) << std::fixed << pi << std::endl; std::cout << std::setprecision(2) << std::scientific << pi << std::endl; return 0; }
1 2
3.14 3.14e+00