# C++()-c++

## C++()

### 随机数生成器

uniform_int_distribution 生成 $$[a, b]$$ 的随机数

uniform_real_distribution 生成 $$[a,b)$$ 的随机数

const int ADDR = 1;
mt19937 rd = mt19937(种子)
int rr(int l, int r){
uniform_int_distribution<int> d(l, r);
return d(rd);
}


### 实用算法

partial_sum(first, last, first)
partial_sum(first, last, first, op)


adjacent_difference(first, last, first)


hypot(x, y)


minmax(x, y)


min_element(first, last)
max_element(first, last)
min_max_element(first, last)


min(list)
max(list)


$$[first, mid)$$, $$[mid, last)$$ 进行归并排序

merge(first1, last1, first2, last2, first3)
inplace_merge(first, mid, last)


partion(first, last, p)
stable_partion(first, last, p)


count(first, last, value)
count_if(first, last, p)


partial_sort(first, mid, last)


nth_element(first, nth, last)


n_first 成为新序列的首个元素，n_first – 1 成为新序列的最后一个元素

rotate(first, nth, last)


bind()


struct base{
...
}
struct son : base{

}


base :: f()


template<typename T, int N>
struct mvector : array<T, N>{
int cur = 0;
void push_back(const T& x){
array<T, N> ::operator[](cur) = x;
++cur;
}
void pop_back(){
--cur;
}
bool empty(){
return cur == 0;
}
int size(){
return cur;
}
auto end(){
return array<T, N>::begin() + cur;
}
};


### 实用流

stringstream（严格快于sscanf / sprintf）

### 实用容器

array<T, N>


basic_string<T>


### 实用语言特性

lambda 表达式

std::function<> f;

————————

### 随机数生成器

uniform_int_distribution 生成 $$[a, b]$$ 的随机数

uniform_real_distribution 生成 $$[a,b)$$ 的随机数

const int ADDR = 1;
mt19937 rd = mt19937(种子)
int rr(int l, int r){
uniform_int_distribution<int> d(l, r);
return d(rd);
}


### 实用算法

partial_sum(first, last, first)
partial_sum(first, last, first, op)


adjacent_difference(first, last, first)


hypot(x, y)


minmax(x, y)


min_element(first, last)
max_element(first, last)
min_max_element(first, last)


min(list)
max(list)


$$[first, mid)$$, $$[mid, last)$$ 进行归并排序

merge(first1, last1, first2, last2, first3)
inplace_merge(first, mid, last)


partion(first, last, p)
stable_partion(first, last, p)


count(first, last, value)
count_if(first, last, p)


partial_sort(first, mid, last)


nth_element(first, nth, last)


n_first 成为新序列的首个元素，n_first – 1 成为新序列的最后一个元素

rotate(first, nth, last)


bind()


struct base{
...
}
struct son : base{

}


base :: f()


template<typename T, int N>
struct mvector : array<T, N>{
int cur = 0;
void push_back(const T& x){
array<T, N> ::operator[](cur) = x;
++cur;
}
void pop_back(){
--cur;
}
bool empty(){
return cur == 0;
}
int size(){
return cur;
}
auto end(){
return array<T, N>::begin() + cur;
}
};


### 实用流

stringstream（严格快于sscanf / sprintf）

### 实用容器

array<T, N>


basic_string<T>


### 实用语言特性

lambda 表达式

std::function<> f;