当前位置:网站首页>Leetcode刷题题解2.1.1
Leetcode刷题题解2.1.1
2022-07-06 08:49:00 【好久不见0327】
distance()函数用于计算两个迭代器表示的范围内包含元素的个数
template<class Inputlterator>
typename iterator_traits<Inputlterator>::difference_type distance(Inputlterator first, Inputlterator last);#include<iostream>
#include<iterator>
#include<list>
using namespace std;
int main() {
// 创建一个空list容器
list<int> mylist;
// 向空的list容器中添加元素0~9
for (int i = 0; i < 10; i++) {
mylist.push_back(i);
}
// 指定2个双向迭代器,用于执行某个区间
list<int>::iterator first = mylist.begin(); // 指向元素0
list<int>::iterator last = mylist.end(); // 指向元素9之后的位置
// 获取[first, last)范围内包含元素的个数
cout << "distance() = " << distance(first, last);
return 0;
}unique函数的功能是元素去重。即“删除”序列中所有相邻的重复元素(只保留一个)
边栏推荐
- 个人电脑好用必备软件(使用过)
- The network model established by torch is displayed by torch viz
- [MySQL] limit implements paging
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- 深度剖析C语言指针
- MYSQL卸载方法与安装方法
- What are the common processes of software stress testing? Professional software test reports issued by companies to share
- 可变长参数
- Roguelike game into crack the hardest hit areas, how to break the bureau?
- 游戏解包的危害及资源加密的重要性
猜你喜欢
随机推荐
sublime text中conda环境中plt.show无法弹出显示图片的问题
[MySQL] multi table query
CSP first week of question brushing
Deep analysis of C language pointer
Using pkgbuild:: find in R language_ Rtools check whether rtools is available and use sys The which function checks whether make exists, installs it if not, and binds R and rtools with the writelines
Roguelike game into crack the hardest hit areas, how to break the bureau?
Browser thread
On the inverse order problem of 01 knapsack problem in one-dimensional state
【ROS】usb_ Cam camera calibration
C language double pointer -- classic question type
LeetCode:41. 缺失的第一个正数
Screenshot in win10 system, win+prtsc save location
Shift Operators
After PCD is converted to ply, it cannot be opened in meshlab, prompting error details: ignored EOF
Philosophical enlightenment from single point to distributed
To effectively improve the quality of software products, find a third-party software evaluation organization
pytorch查看张量占用内存大小
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
被破解毁掉的国产游戏之光





![[embedded] print log using JLINK RTT](/img/22/c37f6e0f3fb76bab48a9a5a3bb3fe5.png)



