#include <iomanip>
cout << manipulator
setw
n
.
n
character spaces.
cout << setw(10) << "hello"
_____hello
(assume _ is a space)
n
is too small, the normal output will occur.
cout << setw(2) << "hello"
hello
showpoint
fixed
and scientific
defaultfloat
restores the result.
setprecision(n)
123456789012345678901234567890 // this line is not part of the output. n 3 1/n 0.33333 // accurate to five decimal places n+n 6 n^2 9 n^3 27 n! 6 sqrt(n) 1.732 // accurate to three decimal places