This is the 8th day of my participation in Gwen Challenge
Real,
Scientific enumeration
3e2 =3*10^2
3e-2 = 3*10^2 -
Copy the code
Single precision
float 4One byte precision type4Bytes (32Bit memory space +/-3.4e +/- 38 (7Bit significant digit)Copy the code
double
double 8Two bytes of double precision accounted for8Bytes (64Bit memory space +/-1.7e +/- 308 (15~16Bit significant digit)Copy the code
Long double
long double 16A one-byte long double16Bytes (128Bit) memory space is available18- 19Bit significant digit.Copy the code
details
// Add f to float,Because the compiler defaults to decimalsdouble, will be compiled fromdoubleintofloat
float a = 3.14 f;
double b= 3.14;
Copy the code
character
Function:
Display a single characterCopy the code
Grammar:
char ch = 'a'; Byte:1Scope:- 128. 到 127or0 到 255
Copy the code
Note:
Use single quotation marks to enclose characters, but cannot use double quotation marks. Single quotation marks contain only one character, but cannot contain stringsCopy the code
ASCII and escape characters
// The character variable corresponds to the ASCII encoding 'a'-97 'a' -65
char ch ='a';
cout<<ch<<""< < (int)ch<<endl;
// Commonly used escape characters
\n // newline ASCII value 10
\t // Horizontal TAB with ASCII value 9\ \// a backslash
Copy the code
string
/ / C language
char str[]="hello world";
cout<<str<<endl;
//c++
// start file
string str = "hello world";
cout<<str<<endl;
Copy the code
Boolean (bool)
// Non-zero is true
// It takes 1 byte
bool flag = true(nature is1);
cout<<flag<<endl;
Copy the code
Data input
Standard Input Stream (CIN) The predefined object CIN is an instance of the IoStream class. Cin objects are attached to a standard input device, usually a keyboard. Cin is used in conjunction with the stream extract operator >>,/ / cin > > variables
int a;
cin>>a;
cout<<a;
// Other types are similar
Copy the code
summary
Also due to acm, I learned c++ in the winter vacation of my freshman year, but it was only simple and basic usage without systematic learning. At that time, I mainly wanted to improve the speed and convenience of code writing, because c++ has STL. But, after all, c + + is an object-oriented language, to say the prior knowledge of c + + is really based on c on the expansion of basically not counting introduction, after learning the Java suddenly to the object-oriented c + + has the interest, with a c + + because of the acm, although object-oriented not to use it, but also have certain obsession on it.