当前位置:网站首页>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);
边栏推荐
- C语言读取BMP文件
- csdn-Markdown编辑器
- 【博主推荐】asp.net WebService 后台数据API JSON(附源码)
- Dotnet replaces asp Net core's underlying communication is the IPC Library of named pipes
- Introduction to the easy copy module
- 机器学习--人口普查数据分析
- MySQL master-slave replication, read-write separation
- Kept VRRP script, preemptive delay, VIP unicast details
- MySQL主从复制、读写分离
- PyCharm中无法调用numpy,报错ModuleNotFoundError: No module named ‘numpy‘
猜你喜欢

打开浏览器的同时会在主页外同时打开芒果TV,抖音等网站
![[recommended by bloggers] asp Net WebService background data API JSON (with source code)](/img/04/c721e6177b578b30cbbf334cb1b6c9.png)
[recommended by bloggers] asp Net WebService background data API JSON (with source code)

Request object and response object analysis

Install mysql5.5 and mysql8.0 under windows at the same time

MySQL主从复制、读写分离

QT creator custom build process

Case analysis of data inconsistency caused by Pt OSC table change

Introduction and use of automatic machine learning framework (flaml, H2O)

When you open the browser, you will also open mango TV, Tiktok and other websites outside the home page

QT creator create button
随机推荐
Cookie setting three-day secret free login (run tutorial)
[Thesis Writing] how to write function description of jsp online examination system
【博主推荐】asp.net WebService 后台数据API JSON(附源码)
vs2019 桌面程序快速入门
Remember a company interview question: merge ordered arrays
AcWing 1294.樱花 题解
One click extraction of tables in PDF
The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
Classes in C #
【博主推荐】SSM框架的后台管理系统(附源码)
Base de données Advanced Learning Notes - - SQL statements
Use dapr to shorten software development cycle and improve production efficiency
Armv8-a programming guide MMU (2)
MySQL的一些随笔记录
Ansible practical Series II_ Getting started with Playbook
自动机器学习框架介绍与使用(flaml、h2o)
Ubuntu 20.04 安装 MySQL
Deoldify项目问题——OMP:Error#15:Initializing libiomp5md.dll,but found libiomp5md.dll already initialized.
LeetCode #461 汉明距离
Database advanced learning notes -- SQL statement