标签:name std clear code mes class amp gre bsp
1 #include<bits/stdc++.h> 2 using namespace std; 3 set<int,greater<int> >S; //从大到小排 4 //set<int>S; 从小到大排 5 int main() 6 { 7 for(int i=1;i<=5;i++){ 8 int tmp; 9 scanf("%d",&tmp); 10 S.insert(tmp); //插入元素 11 } 12 for(set<int>::iterator it=S.begin();it!=S.end();it++){ 13 printf("%d ",*it); //遍历元素,只能这样遍历 14 } 15 printf("\n"); 16 S.erase(5); //删除某个元素 17 for(set<int>::iterator it=S.begin();it!=S.end();it++){ 18 printf("%d ",*it); 19 } 20 printf("\n"); 21 int len=S.size(); 22 printf("len:%d\n",len); 23 S.clear(); 24 if(!S.empty()) printf("kong\n"); 25 else printf(" no kong \n"); 26 }
标签:name std clear code mes class amp gre bsp
原文地址:https://www.cnblogs.com/pangbi/p/12409067.html