当前位置:网站首页>Library function -- (continuous update)
Library function -- (continuous update)
2022-07-06 11:24:00 【%xiao Q】
isdigit(): Judge whether the input characters are composed of numbers
char ch;
isdigit(ch)
Random function
srand((unsinged)(time(0))); // Random seeds
int x = rand() % 100 // 0 ~ 100 Number of numbers
Dichotomous function
// Return is greater than the val The address of the value of
upper_bound(a.begin(), a.end(), val);
upper_bound(a, a + n, val, val);
// Return greater than or equal to val The address of the value of
upper_lower(a.begin(), a.end(), val);
upper_lower(a, a + n, val);
Integer to string
int num;
string s = to_string(nmu);
Copy function ( Copy an array to another array )
// vector<> Exchange of containers
vector<int> a, b;
a.assign(b.begin(), b.end()); // hold b Copy to a
// a[] The exchange of arrays
int a[N], b[N];
memcpy(a, b, sizeof b); // hold b Copy to a
sqrt() and log() The return value of the function is floating point
All permutation functions
// n by a The length of the array
next_permutataion(a, a + n) // Next in ascending order , namely 1 2 3 -> 1 3 2 -> 2 1 3 ... , 3 2 1 , And the next if there is a return 1, Otherwise return to 0
prev_permutation(a, a + n) // Next in descending order , namely 3 2 1 -> 3 1 2 ... 1 2 3, And the next if there is a return 1, Otherwise return to 0
Subsequences and substrings
Substring : Successive
Subsequence : It can be discontinuous
Definition of small root heap and large root heap
priority_queue<int> q; // Big root pile
priority_queue<int, vector<int>, greater<int>> q; // Heap
sort From big to small (2 Methods )
int a[N];
sort(a, a + n, greater<int>()) // The in angle brackets are defined according to the array type
bool cmp(int x, y)
{
return x >= y;
}
int main()
{
int a[N];
sort(a, a + n, cmp);
}
All permutation functions (c++)
int a[N];
do
{
...
}next_permutation(a, a + n); // Achieve ascending order
do
{
...
}prev_permutation(a, a + n) // Achieve descending order
Dichotomous function
- lower_bound(): Return greater than or equal to x Array subscript Address
- upper_bound(): Return is greater than the x Array subscript Address
If this number does not exist in the array , Then the array length will be returned .
int t = lower_bound(a, a + n, x) - a; // Because the return is the address , So we need to -a, That is, subtract the array name
int t = upper_bound(a, a + n, x);
边栏推荐
- [recommended by bloggers] C MVC list realizes the function of adding, deleting, modifying, checking, importing and exporting curves (with source code)
- Data dictionary in C #
- Install MySQL for Ubuntu 20.04
- FRP intranet penetration
- AcWing 179. Factorial decomposition problem solution
- 连接MySQL数据库出现错误:2059 - authentication plugin ‘caching_sha2_password‘的解决方法
- Deoldify项目问题——OMP:Error#15:Initializing libiomp5md.dll,but found libiomp5md.dll already initialized.
- vs2019 第一个MFC应用程序
- What does usart1 mean
- Unable to call numpy in pycharm, with an error modulenotfounderror: no module named 'numpy‘
猜你喜欢

Request object and response object analysis

打开浏览器的同时会在主页外同时打开芒果TV,抖音等网站

QT creator create button

【博主推荐】asp.net WebService 后台数据API JSON(附源码)

Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'

Deoldify project problem - omp:error 15:initializing libiomp5md dll,but found libiomp5md. dll already initialized.
![[蓝桥杯2017初赛]方格分割](/img/e9/e49556d0867840148a60ff4906f78e.png)
[蓝桥杯2017初赛]方格分割

LeetCode #461 汉明距离

引入了junit为什么还是用不了@Test注解

In the era of DFI dividends, can TGP become a new benchmark for future DFI?
随机推荐
Neo4j installation tutorial
Error reporting solution - io UnsupportedOperation: can‘t do nonzero end-relative seeks
Django running error: error loading mysqldb module solution
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
AcWing 242. A simple integer problem (tree array + difference)
数据库高级学习笔记--SQL语句
Cookie setting three-day secret free login (run tutorial)
[蓝桥杯2021初赛] 砝码称重
CSDN markdown editor
[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP
Use dapr to shorten software development cycle and improve production efficiency
QT creator create button
一键提取pdf中的表格
[蓝桥杯2020初赛] 平面切分
Pytorch基础
Remember the interview algorithm of a company: find the number of times a number appears in an ordered array
Introduction and use of automatic machine learning framework (flaml, H2O)
L2-006 树的遍历 (25 分)
01项目需求分析 (点餐系统)
Deoldify project problem - omp:error 15:initializing libiomp5md dll,but found libiomp5md. dll already initialized.