当前位置:网站首页>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 .
边栏推荐
- [IOT design. Part I] stm32+ smart cloud aiot+ laboratory security monitoring system
- Research Report on the development trend and competitive strategy of the global indexable milling cutter industry
- [零基础学IoT Pwn] 复现Netgear WNAP320 RCE
- sqlilabs less9
- 微服务开发步骤(nacos)
- Provincial election + noi Part IX game theory
- [getting started with Django] 13 page Association MySQL "multi" field table (check)
- sqlilabs less13
- Realize queue with stack and stack with queue (C language \leetcode\u 232+225)
- Fundamentals of C language
猜你喜欢

建立自己的网站(14)

Word2vec yyds dry goods inventory

phpcms实现订单直接支付宝支付功能
![[Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize](/img/30/aea4ae24f418eb971bca77a1d46bef.png)
[Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize

【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
![[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system](/img/b2/e8f81ecda6f5f4fc65501aaf9f13cf.gif)
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system

Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server

"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

户外LED显示屏应该考虑哪些问题?

MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
随机推荐
Semiconductor foundation of binary realization principle
生成随机数(4位、6位)
光环效应——谁说头上有光的就算英雄
sqlilabs less-8
Develop small programs and official account from zero [phase III]
What problems should be considered for outdoor LED display?
Yyds dry goods inventory hcie security day13: firewall dual machine hot standby experiment (I) firewall direct deployment, uplink and downlink connection switches
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
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
Vnctf2022 open web gocalc0
JVM performance tuning and practical basic theory part II
一波三折,终于找到src漏洞挖掘的方法了【建议收藏】
sqlilabs less10
Research Report on development trend and competitive strategy of global consumer glassware industry
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
【15. 区间合并】
How to pass array parameters in get request
WebSocket(简单体验版)
[R language data science]: common evaluation indicators of machine learning
Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界