auto

Use auto

STH in for (auto I: STH) can be something with an iterator, and I is each element in STH

Attribute of comparison

Less, less_equal, greater (from large to small), greater_equal are in the header file functional

Int bar [] = 15,10,20 {};

std::sort (bar, bar+3, std::less()); // from small to big

The string class

// constructor

String STRS // Generates an empty string

String s(STR) // Generates a copy of the string STR

@string s(STR, stridx) // Take the part of the string STR that begins with stridx as the initial value of the constructor

@string s(STR, strbegin, strlen) // Take the strlen part of the string beginning with strbegin as the initial value

String s(CSTR) // Use C_string CSTR as the initial value of string s

String s(CSTR,char_len) // Use the first char_len of C_string CSTR as the initial value of string s

Strings (num, c) // Generates a string containing num c characters

Strings (STRS, beg, end) // take characters from the interval [beg, end] (both iterators) as the initial value of strings

The above method of @ line can be applied to all functions

//c_str()

There is an implicit conversion from const char * to string, but there is no automatic conversion from string to C_string. String.c_str () returns C_string.

/ / the length

Length () or size() returns the length of the string

/ / to compare

S pare (pos,n, s2,pos2,n2)// use s-s2, return 1, -1,0

Lexicographical orders can be compared directly with the comparison operator

// Modify and replace

Str.assign (str1)// Assign str1 to STR

erase()

s.swap(s1)

insert()

append()

replace()

/ / input

The third argument to getline(cin,s) specifies the terminator

/ / to find

Find () before, rfind() after

Pair class (header Utility)

/ / structure

auto my_pair=make_pair(a,b)

Pair < type, type > my_pair(a,b)

/ / access

My_pair. First or second

/ / to compare

First before second, in lexicographical order

/ / exchange

Swap () function

Map class (default sort is less)

/ / structure

Each pair can be either {a,b} or make_pair(a,b)

/ / insert

Insert (pair object)

Count (STR)// Counts the number of occurrences of STR in each key

Emplace (a,b)// insert {a,b} as a pair

/ / to find

Find ()// Returns the iterator type

/ / the length

size()

/ / access

Value is accessed directly by key using subscripts

/ / delete

Erase (key)// Delete the pair corresponding to the key