c++怎样指定小数点后几位

#include

cout<<"Case "<

指定小数点后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


你可能感兴趣的:(c++)