![]() |
#2
幽竹烟雨2019-02-17 11:05
|

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class F
{
public:
F(vector<int> t):_v(t){}
bool operator()(int i,int j)
{
if(count(_v.begin(),_v.end(),i)!=1)
return true;
else
return false;
}
private:
vector<int> _v;
};
int main()
{
vector<int> arr1{1,2,3,4,4,5,6,5,6};
arr1.erase(unique(arr1.begin(),arr1.end(),F(arr1)),arr1.end());
for_each(begin(arr1),end(arr1),[](int i)
{
cout<<i<<' ';
});
cout<<endl;
return 0;
}
程序运行结果为1 2 3 4,正确结果应为1 2 3 4 5 6
求指教。