当前位置:网站首页>Some common functions and precautions
Some common functions and precautions
2022-06-30 03:12:00 【Rivers overflow】
next_permutation()
#include<bits/stdc++.h>
using namespace std;
signed main(void)
{
int a[10]={1,2,3};
do
{
printf("%d%d%d\n",a[0],a[1],a[2]);
}while(next_permutation(a,a+3));//a[0] To a[2] Full Permutation
return 0;
}fill()
#include<bits/stdc++.h>
using namespace std;
signed main(void)
{
int a[10];
fill(a,a+5,3);
for(int i=0;i<5;i++)
cout<<a[i]<<" ";
return 0;
}sort()
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
signed main(void)
{
vector<int> p1;
p1.push_back(4);
p1.push_back(2);
p1.push_back(9);
sort(p1.begin(),p1.end(),cmp);
cout<<p1[0]<<" "<<p1[1]<<" "<<p1[2]<<endl;
return 0;
}
//9 4 2lower_bound(first,last,val),upper_bound(first,last,val), Both are left closed and right open sections
If it is an array, return the pointer , The container returns an iterator , If the target element is not found , Returns the position where the element should be if it exists ( For other features, see the author's previous lower_bound、upper_bound)
Be careful : many STL The interval in is left closed and right open , for example sort Yes a[1] To a[n] row The preface should be written as sort(a+1,a+1+n) wait
边栏推荐
- Auto. JS learning notes 15:ui interface basics of autojs Chapter 2
- Servlet面试题
- Use compose to realize the effect of selecting movie seats by panning tickets
- On the role of database tables
- 备忘一下es6的export/import和类继承的用法
- (graph theory) connected component (template) + strongly connected component (template)
- 广播模块代码在autojs4.1.1版本运行正常,但在pro7.0版本上运行报错(未解决)
- mysqldump原理
- How to switch ipykernel to a different CONDA virtual environment in jupyterlab?
- Problem record: FEL_ lib. c:26:10: fatal error: libusb. h: There is no such file or directory
猜你喜欢

Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load

The MariaDB database was found 12 hours late

中断操作:AbortController学习笔记

The broadcast module code runs normally in autojs4.1.1, but an error is reported in pro7.0 (not resolved)

什么是外链和内链?
![[practical skills] how to write agile development documents](/img/38/4bab396891ce3cc42595ae8cfd45ce.png)
[practical skills] how to write agile development documents

约瑟夫环 数学解法

QT中foreach的使用

Use of Arthas

发现mariadb数据库时间晚了12个小时
随机推荐
Servlet面试题
uniapp 地址转换经纬度
Wechat applet +php to realize authorized login operation
Jvxetable sub table record loading completion event
【十分钟】manim安装 2022
Note the use of export/import and class inheritance in ES6
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
Interrupt operation: abortcontroller learning notes
Summary of interview and Employment Questions
快速排序、聚簇索引、尋找數據中第k大的值
*Write a program to initialize a string object with a vector < char> container*/
The rigorous judgment of ID number is accurate to the last place in the team
List of development tools
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
C console format code
What is the concept of string in PHP
ZABBIX trigger explanation
产品思维 | 无人机快递的未来值得期待吗?
Distributed file storage system fastdfs hands on how to do it
Possible problems in MySQL cross database operation with database name