Today try to NOI OJ 1.1, casually summed up.
"cout left-to-aligns alignment method"
1#include <iostream>2#include <cstdio>3#include <iomanip>//SETW Required header file4 using namespacestd;5 6 intMain ()7 {8 intA=1, b= at, c=456;9 //scanf ("%d%d%d", &a,&b,&c);Ten One /*defines a width of 8, the default right-aligned output*/ ACOUT<<SETW (8) <<a<<' '<<SETW (8) <<b<<' '<<SETW (8) <<c<<Endl; - - /*as can be seen from the following statement, SETW (n) only for the next valid*/ theCOUT<<SETW (8) <<a<<' '<<b<<Endl; - - /*left-aligned output needs to be declared*/ -COUT<<LEFT<<SETW (8) <<B<<LEFT<<SETW (8) <<c<<Endl; + return 0; -}
"Floating-point control (keep n decimals)"
1#include <iostream>2#include <cstdio>3 using namespacestd;4 5 intMain ()6 {7 floatA;8scanf"%f",&a);9printf"%.3f", a);Ten return 0; One}
%f means output in floating-point number format
%e represents the format output of floating-point numbers in exponential form
%g indicates that the appropriate representation output is selected automatically
Input and output of "C + + with notes" programming basis