64,685
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool same_elem(vector<int>& v1,vector<int>& v2)
{
vector<int> vt(v1.begin(),v1.end());
vector<int>::iterator itu;
copy(v2.begin(),v2.end(),back_inserter(vt));
sort(vt.begin(),vt.end());
itu=unique(vt.begin(),vt.end());
if(itu==vt.end())
return 0;
else
return 1;
}
int main(void)
{
vector<int> v1,v2;
v1.push_back(1);
v1.push_back(6);
v1.push_back(3);
v2.push_back(5);
v2.push_back(3);
if(same_elem(v1,v2))
cout<<"v1 v2 have same element"<<endl;
else
cout<<"v1 v2 don't have same element"<<endl;
system("pause");
return 0;
}