using namespace std 是其中oop的一个特性。

using namespace std 可以使程序使用std名称空间里面的定义。


C++ 多了  endl 换行

可以用 int e(1)或者 int e {1}来定义变量。

C++ 还通过 cout来实现格式化输出。

cout.setf(ios_base::fixed,ios_base:floatfiled) 这个的意思就是正常的计数方式显示浮点数,另外小数点后保留6位。

cout 调用的setf()函数有两个原型,

fmtflags setf(fmtflage) //第一原型

fmtflags setf(fmtflags, fmtflags) //第二原型

boolalpha 可以使用单词"true"和"false"进行输入/输出的布尔值.
oct 用八进制格式显示数值.
dec 用十进制格式显示数值.
hex 用十六进制格式显示数值.
left 输出调整为左对齐.
right 输出调整为右对齐.
scientific 用科学记数法显示浮点数.
fixed 用正常的记数方法显示浮点数(与科学计数法相对应).
showbase 输出时显示所有数值的基数.
showpoint 显示小数点和额外的零,即使不需要.
showpos 在非负数值前面显示"+(正号)".
skipws 当从一个流进行读取时,跳过空白字符(spaces, tabs, newlines).
unitbuf 在每次插入以后,清空缓冲区.
internal 将填充字符回到符号和数值之间.
uppercase 以大写的形式显示科学记数法中的"e"和十六进制格式的"x".


第二个参数                    第一个参数              含义
ios_base::basefield       ios_base::dec    使用10进制
                          ios_base::oct    使用8进制
                          ios_base::hex    使用16进制
ios_base::floatfield      ios_base::fixed    使用定点计数法(即一般计数法)
                          ios_base::scientific    使用科学计数法
ios_base::adjustfield     ios_base::left    左对齐
                          ios_base::right    右对齐
                          ios_base::internal    符合或前缀左对齐,值右对齐


vector<type> variable name  动态数组,

list<type> variable name 列表

vector 可以随意的添加元素进去,但是这个效率不高。

Vectors are sequence containers representing arrays that can change in size.

Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.

Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it. This is a relatively expensive task in terms of processing time, and thus, vectors do not reallocate each time an element is added to the container.

Instead, vector containers may allocate some extra storage to accommodate for possible growth, and thus the container may have an actual capacity greater than the storage strictly needed to contain its elements (i.e., its size). Libraries can implement different strategies for growth to balance between memory usage and reallocations, but in any case, reallocations should only happen at logarithmically growing intervals of size so that the insertion of individual elements at the end of the vector can be provided with amortized constant time complexity (see push_back).

Therefore, compared to arrays, vectors consume more memory in exchange for the ability to manage storage and grow dynamically in an efficient way.

Compared to the other dynamic sequence containers (deques, lists and forward_lists), vectors are very efficient accessing its elements (just like arrays) and relatively efficient adding or removing elements from its end. For operations that involve inserting or removing elements at positions other than the end, they perform worse than the others, and have less consistent iterators and references than lists and forward_lists.



char16_t char32_t

auto  自动转成第一次赋值的类型。

强制类型转换的两种格式:(typeName)value    typeName(value)