c++はどのように小数点の後の何桁を指定します

732 ワード

#include
cout<
小数点以下5桁指定
   showpoint ,          10           0 
fixed            ,       100.00000
scientific          。  1.00000e+002
 
  
 
  
int main () {
  double a, b, pi;
  a=30.0;
  b=10000.0;
  pi=3.1416;
  cout.precision (5);
  cout <<   showpoint << a << '\t' << b << '\t' << pi << endl;
  cout << noshowpoint << a << '\t' << b << '\t' << pi << endl;
  return 0;
}

The execution of this example displays something similar to:

30.000  10000.  3.1416
30      10000   3.1416