Learning C ++
- Input and output header file
First, the input and output
(1) cin and cout
C ++ can also be used printf and scanf, but compared to this, cin and cout a little easier. Let's first look at a piece of code.
operation result:
Where n inputs and outputs with the COUT using cin; with m inputs and outputs of scanf and printf.
The former can clearly feel very convenient to use, and is no longer considered "% d", or "% f", etc. at the input and output. Scanf inputs and '&' character addresses do not have to worry about missing write.
Note. 1: CIN using cout must be added (using namespace std;) until the following header, main function syntax. Otherwise, you can not use or can be used as needed in the manner the following figure:
Note 2: The need to add cin and cout double arrow when use, we must note that cin >>, cout << is.
Using (2) endl of
Code section:
operation result:
Here you can own a pondering Ha! I think that was directly "\ n" a little more convenient, it depends on your preferences. (Note that the eclipse is not the same as you can not use the '+' to connect String type int type and the like. << still need to be connected)
Note: Under what circumstances need to use printf and scanf it? If in the contest, some topics require a higher time complexity, this time with printf and scanf can improve the input output efficiency of the code.
Second, the header file
More common header file:
#include <the iostream> (IO: input and output, stream:. Flow so this header file are managed in a number of input and output streams)
#include<cmath> (相当于c语言里面的#include<math.h>)
#include<cctype>(相当于c语言里面的#include<ctype.h>)
#include<cstdio>(相当于c语言里面的#include<stdio.h>)
#include<cstring>(相当于c语言里面的#include<string.h>)