首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

set_union在那个库?该怎么解决

2013-04-02 
set_union在那个库?#pragma warning(disable : 4786)#include iostream#include iterator#include st

set_union在那个库?

#pragma warning(disable : 4786)
#include <iostream>
#include <iterator>
#include <string>
#include <set>

int main()
{
using namespace std;
const int N = 6;
string s1[N] = {"buffoon", "thinkers", "for", "heavy", "can", "for"};
string s2[N] = {"metal", "any", "food", "elegant", "deliver", "for"};

set<string> A(s1, s1 + N);
set<string> B(s2, s2 + N);//加到N是因为是超尾的关系
ostream_iterator<string, char> out(cout, " ");
cout << "Set A:";
copy(A.begin(), A.end(), out);
cout << endl;
cout << "Set B:";
copy(B.begin(), B.end(), out);
cout << endl;

cout << "Union of A and B:\n";
set_union(A.begin(), A.end(), B.begin(), B.end(), out);
cout << endl;

cout << "Intersection of A and B:\n";
set_intersection(A.begin(), A.end(), B.begin(), B.end(), out);
cout << endl;



return 0;
}


为什么总是出现error C2065: 'set_union' : undeclared identifier
和error C2065: 'set_intersection' : undeclared identifier
[解决办法]
#include <algorithm> 

热点排行