算法 | 返回值 | 作用 |
find_end() | _FwdIt1 | 搜索某个子序列的最后一次出现地点 |
find_frist_of() | _FwdIt1 | 搜索某些元素的首次出现位置 |
find_end()的参数 | _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2 | |
find_frist_of()的参数 | _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2 |
vector<int> createStaticArr()
{
vector<int> vectorInt;
vectorInt.push_back(1);
vectorInt.push_back(2);
vectorInt.push_back(3);
vectorInt.push_back(4);
vectorInt.push_back(5);
vectorInt.push_back(6);
vectorInt.push_back(7);
vectorInt.push_back(8);
showArr(vectorInt);
return vectorInt;
}
vector<int> createStaticArrTwo()
{
vector<int> vectorInt;
vectorInt.push_back(1);
vectorInt.push_back(2);
vectorInt.push_back(3);
vectorInt.push_back(4);
vectorInt.push_back(5);
vectorInt.push_back(9);
vectorInt.push_back(8);
vectorInt.push_back(7);
showArr(vectorInt);
return vectorInt;
}
void showArr(vector<int> Arr)
{
vector<int>::iterator iteArr = Arr.begin();
for (iteArr ; iteArr != Arr.end(); iteArr++)
{
cout << *iteArr << "\t";
}
cout << endl;
}
void main()
{
cout << "第一条:"; vector<int> arr1 = createStaticArr();
cout << "第二条:"; vector<int> arr2 = createStaticArrTwo();
//排序
sort(arr2.begin(),arr2.end());
vector<int>::iterator iteLeft;
iteLeft = find_end(arr1.begin(), arr1.begin()+5, arr2.begin(), arr2.end());
cout << *iteLeft << endl;
iteLeft = find_first_of(arr1.begin(), arr1.begin() + 5, arr2.begin(), arr2.end());
cout << *iteLeft << endl;
}
运行结果: