find_first_of

来源:互联网 发布:查看网络有几个人用 编辑:程序博客网 时间:2024/06/06 10:49
    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;
    }

    cout << endl;


找出两个数组的相同的元素

原创粉丝点击