C++ STL

View Code
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 100100;
vector < pair<int, int> > v;
vector <int> a, b, c;
#define ALL(c) c.begin(), c.end()

int main()
{
    int i, j;
    for(i = 1; i <= 10; i++)
        a.push_back(i);
    for(i = 5; i <= 15; i++)
        b.push_back(i);
    a.erase(remove(a.begin(), a.end(), 3), a.end());
    for(i = 0; i < a.size(); i++)
        cout << a[i] << endl;
    c.resize(11);
    set_intersection(ALL(a), ALL(b), c.begin());   
    for(i = 0; i < c.size(); i++)
        cout << c[i] << endl;
    set_difference(ALL(a), ALL(b), c.begin());
    for(i = 0; i < c.size(); i++)
        cout << c[i] << endl;

    return 0;
}
posted @ 2012-12-01 20:40  To be an ACMan  Views(138)  Comments(0)    收藏  举报