📄 iterator_distance.cpp
字号:
#include<iterator>
#include<vector>
#include <iostream>
using namespace std;
const int MAX = 4;
int main()
{
int numbers_array[MAX];
vector<int> numbers_vector(MAX);
for (int loop_index = 0; loop_index < MAX; loop_index++){
numbers_array[loop_index] = loop_index;
}
copy(numbers_array, numbers_array + MAX, numbers_vector.begin());
vector<int>::iterator itr = numbers_vector.begin() + 2;
vector<int>::difference_type itr_distance;
distance(numbers_vector.begin(), itr, itr_distance);
cout << "The distance from the beginning to the iterator is: "
<< itr_distance << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -