D
Davy
Hi all,
I want to use set_intersection, and the compiler passed with a warning.
But the program hang on when it enter set_intersection(), why?
And how can I insert element to set by insert();
BTW, I use VC6.0(is it too old?).
//---The code listed:---//
#include <math.h>
#include <fstream.h>
#include <algorithm>
#include <iterator>
#include <set>
using namespace std;
typedef set<int> Set_int;
typedef set<int>:: iterator It;
int main() {
int int_1[]={1,4,3,2,5};
int int_2[]={7,8,4,5,0,100};
int x = 1000;
Set_int s1 (int_1,int_1+5);
Set_int s2 (int_1,int_1+6);
Set_int s3;
It it=set_intersection(s1.begin(), s1.end(),\
s2.begin(), s2.end(),\
inserter(s3, s3.begin()));
//s3.erase(it,s3.end());
s3.insert(x);
for(It j=s3.begin();j!=s3.end();++j)
cout<<*j<<"\n";
return 0;
}
Best regards,
Davy
I want to use set_intersection, and the compiler passed with a warning.
But the program hang on when it enter set_intersection(), why?
And how can I insert element to set by insert();
BTW, I use VC6.0(is it too old?).
//---The code listed:---//
#include <math.h>
#include <fstream.h>
#include <algorithm>
#include <iterator>
#include <set>
using namespace std;
typedef set<int> Set_int;
typedef set<int>:: iterator It;
int main() {
int int_1[]={1,4,3,2,5};
int int_2[]={7,8,4,5,0,100};
int x = 1000;
Set_int s1 (int_1,int_1+5);
Set_int s2 (int_1,int_1+6);
Set_int s3;
It it=set_intersection(s1.begin(), s1.end(),\
s2.begin(), s2.end(),\
inserter(s3, s3.begin()));
//s3.erase(it,s3.end());
s3.insert(x);
for(It j=s3.begin();j!=s3.end();++j)
cout<<*j<<"\n";
return 0;
}
Best regards,
Davy