# include & ltiostream & gt
# include & ltiomanip & gt// The header file that must be included in the precision setting.
usingnamespacestd
intmain()
{
doublea = 3.5
intb = 10;
//Method 1: Format control of operator functions
//cout.precision(2), and the setting accuracy is 2.
//right: Set left alignment; Fixed: controls the floating-point output format;
//setw(5): Set the output bit width to 5.
Cout & lt& lt Right & lt& lt has been repaired & lt< setw (5) < & ltset fill(“0”)
& lt< setprecision (2)<A<< endl//The output result is 03.50.
//Method 2: Format control of IOS class member functions
cout . precision(4); //setprecision(4), and the setting precision is 4.
The output of cout & lt& lta<& ltendl// is 3.5000.
//setfill('0'): Set the fill character to' 0'
//static _ cast & lt; Double & gt(b): integer b,
//Generate a double-precision floating-point copy for operation without changing its value and type.
Cout & lt& lt has fixed & lt< Setfill ('0') < < setting accuracy (2)
& lt& lt fixed & lt& lt static _ cast & lt double & gt (b) < & ltendl// output 10.00
return0
}