当前位置:网站首页>Reorganize the trivial knowledge points at the end of the term
Reorganize the trivial knowledge points at the end of the term
2022-07-01 14:38:00 【Take you to learn code】
- insert Is for map
- push_back Is for vector
- Use insert when , And use make_pair(,)
- If used pair, Then the data type should be indicated , If used make_pair Do not specify the data type .
- Read file operation ,while() Put... In brackets fstream Later
- Note in file operation ,>> It is a file reading operation ,<< It is a file writing operation , Don't get confused .( Memory method can be understood in this way :cin>>.... cout<<.... cin It's input ,cout It's output .
The first way of understanding :
Output to file , Therefore, the written document corresponds to cout<<
The second way of understanding :
and cin cout Just the opposite
)
7.find lookup ( Is limited to map Container can use this function )
8.map and multimap Special search function of
operation | effect |
count(key) | return ” Key value is equal to key” Number of elements of |
find(key) | return ” Key value is equal to key” The first element of , No return found end |
lower_bound(key) | return ” Key value is greater than or equal to key” The first element of |
upper_bound(key) | return ” The key value is greater than key” The first element of |
equal_range(key) | return ” Key value is equal to key” Element interval of |
especially lower_bound and upper_bound function , In the past, I paid less attention , This exam is inevitable .
9. Consider using set Containers , Take advantage of its automatic weight removal feature .( Don't forget to add #include<set> The header file )
10.
| lower_bound | requirement [first,last) Is ordered , check Find greater than or equal to val The most Small bit Set up |
upper_bound | requirement [first,last) Is ordered , check Find more than val The minimum position of |
11.vector About function sorting
operation | effect |
c.pop_back() | Remove the last element but do not return the last element |
c.erase(pos) | Delete pos The element of location , Returns the position of the next element |
c.erase(beg,end) | Delete range [beg,end] All elements in , Returns the position of the next element |
c.clear() | Remove all elements , Empty the container |
c.resize(num) | Change the number of elements to num( Add elements with defalut Constructors produce , Redundant elements are deleted ) |
c.resize(num,e) | Change the number of elements to num( The added element is e Copy of ) |
c.insert(pos,e) | stay pos Position insert element e Copy of , And return the location of the new element |
c.insert(pos,n,e) | stay pos Position insert n Elements e Copy of |
c.insert(pos,beg,end) | stay pos Position insert interval [beg,end] Copies of all elements in the |
c.push_back(e) | Add an element at the end e Copy of |
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> s;
s.push_back(5);
s.push_back(45);
s.push_back(12);
s.push_back(8);
vector<int>::iterator f=s.begin();
s.insert(f,5,12);
for(f=s.begin();f!=s.end();f++)
{
cout<<*f<<" ";
}
return 0;
} The above figure shows the use of iterators for insert The use of functions that insert multiple elements consecutively .
边栏推荐
- 241. 为运算表达式设计优先级
- 如何看待国企纷纷卸载微软Office改用金山WPS?
- In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
- Halo effect - who says that those with light on their heads are heroes
- Microservice development steps (Nacos)
- Is the futures company found on Baidu safe? How do futures companies determine the regularity
- phpcms实现订单直接支付宝支付功能
- Develop small programs and official account from zero [phase III]
- sqlilabs less13
- Basic knowledge of C language
猜你喜欢
![[dynamic programming] p1004 grid access (four-dimensional DP template question)](/img/3a/3b82a4d9dcc25a3c9bf26b6089022f.jpg)
[dynamic programming] p1004 grid access (four-dimensional DP template question)

One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse
![[14. Interval sum (discretization)]](/img/e5/8b29aca7068a6385e8ce90c2742c37.png)
[14. Interval sum (discretization)]
![[R language data science]: common evaluation indicators of machine learning](/img/c8/dbfb041fa72799fae1892fe8ac0050.png)
[R language data science]: common evaluation indicators of machine learning

"National defense seven sons" funding soared, with Tsinghua reaching 36.2 billion yuan, ranking second with 10.1 billion yuan. The 2022 budget of national colleges and universities was made public

【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程

【14. 区间和(离散化)】
![[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial](/img/44/b65aaf11b1e632f2dab55b6fc699f6.jpg)
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial

Websocket (simple experience version)
![[dynamic programming] interval dp:p1005 matrix retrieval](/img/c9/2091f51b905d2c0ebc978dab3d34d3.jpg)
[dynamic programming] interval dp:p1005 matrix retrieval
随机推荐
C 语言基础
[stage life summary] I gave up the postgraduate entrance examination and participated in the work. I have successfully graduated and just received my graduation certificate yesterday
Quelle valeur le pdnp peut - il apporter aux gestionnaires de produits? Vous savez tout?
2022-2-15 learning xiangniuke project - Section 4 business management
[getting started with Django] 13 page Association MySQL "multi" field table (check)
What problems should be considered for outdoor LED display?
SQLAchemy 常用操作
Research Report on the development trend and competitive strategy of the global high temperature label industry
sqlilabs less-8
MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
[IOT design. Part I] stm32+ smart cloud aiot+ laboratory security monitoring system
一波三折,终于找到src漏洞挖掘的方法了【建议收藏】
"National defense seven sons" funding soared, with Tsinghua reaching 36.2 billion yuan, ranking second with 10.1 billion yuan. The 2022 budget of national colleges and universities was made public
qt捕获界面为图片或label显示
[15. Interval consolidation]
【14. 区间和(离散化)】
Texstudio tutorial
Après avoir été licencié pendant trois mois, l'entrevue s'est effondrée et l'état d'esprit a commencé à s'effondrer.
Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server