First you need to add a header file: Iomanip
One: setprecision
Function: Control the number of floating-point numbers displayed by the output stream, Setprecision (n) is the number of n output, there will be rounding.
For example: Double s=20.7843000
First #include One: setprecisionFunction: Control output stream shows the number of floating-point numbers, Setprecision (n) is the output n number, there will be roundedDouble s=20.7843000;CoutCoutCoutCoutCoutCoutVisible, the fractional part at the
# Include // do not use iostream. h, there will be a lot of problems # include // Io stream control header file, mainly for some operations such as SETW (int n), setprecision (int n ), setbase (int n), setfill (char C.
▲SETW (n) usage: Generally,
// Manipulators (Stream operator) // detailed parsing // use of stream operator fixed and setprecision # include # include using namespace STD; int main () {double num = 123.45678; // by default, the maximum number of digits (including before and
A controller is an object defined in iomanip. h In the header file. Iomanip. h must be included before use
1. I/O writing format
The I/0 stream is a series of input or output bytes. When the program needs to display the output on the screen, you can
CoutSetiosflags is a C + + operator that is contained in the namespace Iomanip, which is the function of executing a parameter specified by theAction within the area;Iso::fixed is one of the parameters of the operator setiosflags, which specifies
C + + formatted output, C + + output format control in the output data, for the sake of simplicity, often do not specify the format of the output, by the system according to the type of data to take the default format, but sometimes you want the
C ++ controller and iomanip ControllerC ++ controller c ++ cout output format
The following header files are often seen in c ++ programs.# Include Io stands for input and output, and manip stands for manipulator.The role of iomanip:This mainly
Introduction: Everyone in the program to write more or less encounter this problem, especially for some beginners will appear this problem, do an ACM contest of students will certainly use C language printf format control output, but accustomed to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.