set 집합 에서 요소 비교

#include<iostream>
#include<vector>
#include<list>
#include<set>
#include<algorithm>
using namespace std;
void Output(char val)
{
    cout << val << ' ';
}
int main()
{
    set<char> cset;
    cset.insert('B');
    cset.insert('C');
    cset.insert('D');
    cset.insert('E');
    cset.insert('F');
    cset.insert('G');
    cout << "old set is " << endl;
    set<char>::iterator it;
    for (it = cset.begin(); it != cset.end(); it++)
        cout << *it << endl;
    set<char> cset1;
    cset1.insert('A');
    cset1.insert('C');
    cset1.insert('D');
    cset1.insert('E');
    cset1.insert('F');
    cset1.insert('G');

    for (it = cset.begin(); it != cset.end(); it++)
        cout << *it << endl;
    if (cset == cset1)
        cout << "cset==cset1" << endl;
    if (cset >cset1)
        cout << "cset>cset1" << endl;
    if (cset < cset1)
        cout << "cset<cset1" << endl;
    system("pause");
    return 0;
}

좋은 웹페이지 즐겨찾기