int a[5] = { 1,3,4,6,7};
int b[5] = { 1,3,5,7,8};
list<int> roster1(a,a+5);
list<int> roster2(b,b+5);
int cnt = 0;
list<int>::iterator it = roster1.begin();
while( ( it = find_first_of(it,roster1.end(),
roster2.begin(),roster2.end())) != roster1.end())
{
++cnt;
cout << *it << " " ;
++it;
}
int b[5] = { 1,3,5,7,8};
list<int> roster1(a,a+5);
list<int> roster2(b,b+5);
int cnt = 0;
list<int>::iterator it = roster1.begin();
while( ( it = find_first_of(it,roster1.end(),
roster2.begin(),roster2.end())) != roster1.end())
{
++cnt;
cout << *it << " " ;
++it;
}
cout << endl;
找出两个数组的相同的元素