1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <deque>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <vector>
#include <map>
using namespace std;
int main(){
int t[]={1,1,2,2,3,3,4,4,5,5};
list<int>v(t,t+10); // v contains the same elements as t
set<int>s1(v.begin(),v.end()); // s1 contains the same as v
if(s1.count(3)==2){ // 3 3 were erased from s1, hence it now has
s1.erase(3); // 1,1,2,2,4,4,5,5
}
for(set<int>::iterator i=s1.begin();i!=s1.end();i++){
cout << *i<<" "; // why 1,2,3,4,5 as output? and why not 1,1,2,2,4,4,5,5. Help please.
}
return 0;
}
|