fig11_26.cpp

来自「经典vc教程的例子程序」· C++ 代码 · 共 25 行

CPP
25
字号
// Fig. 11.26: fig11_26.cpp 
// Displaying floating-point values in system default,
// scientific, and fixed formats.
#include <iostream.h>

int main()
{
   double x = .001234567, y = 1.946e9;

   cout << "Displayed in default format:\n"
        << x << '\t' << y << '\n';
   cout.setf( ios::scientific, ios::floatfield );
   cout << "Displayed in scientific format:\n"
        << x << '\t' << y << '\n';
   cout.unsetf( ios::scientific );
   cout << "Displayed in default format after unsetf:\n" 
        << x << '\t' << y << '\n';
   cout.setf( ios::fixed, ios::floatfield );
   cout << "Displayed in fixed format:\n"
        << x << '\t' << y << endl;
   return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?