set
1 set<int>s1; 2 multiset<int>s2; 3 int x; 4 for(int i=1;i<=3;i++) 5 { 6 scanf("%d",&x); 7 s1.insert(x); 8 s2.insert(x); 9 } 10 for(auto it=s1.begin();it!=s1.end();it++){ 11 cout<<*it<<endl; 12 } 13 cout<<"frvbfeb\n"; 14 for(auto it=s2.begin();it!=s2.end();it++){ 15 cout<<*it<<endl; 16 } 17 18 /* 19 20 21 5 1 1 22 1 23 5 24 frvbfeb 25 1 26 1 27 5 28 29 */
insert
erase
clear
count
1 //遍历 2 set<int>s; 3 int main() 4 { 5 for(int i=1;i<=3;i++) s.insert(i); 6 for(auto x :s) printf("%d\n",x); 7 } 8 1 9 2 10 3
1 char c; 2 int n,y; 3 set<int>se; 4 set<int>::iterator it1,it2,it3; 5 int main() 6 { 7 for(int i=1;i<=5;i++){ 8 se.insert(i); 9 } 10 11 it1 = se.begin(); 12 it2 = se.begin(); 13 it2++;it2++; 14 se.erase(it1,it2);[) 15 printf("%d\n",*it2); 16 17 for(it3=se.begin();it3!=se.end();it3++) printf("%d\n",*it3); 18 return 0; 19 }