set练习

#include<cstdio>
#include<set>
#include<iostream>
using namespace std;

int main()
{
    set<int>jihe;
    jihe.insert(5);
    jihe.insert(2);
    jihe.insert(1);
    jihe.insert(4);
    jihe.insert(3);
    for(set<int>::iterator a=jihe.begin();a!=jihe.end();a++)
    {
        cout<<(*a)<<endl;
    }

    set<int>::iterator b;
    b=jihe.end();//奇怪
    jihe.erase(b);

    for(set<int>::iterator d=jihe.begin();d!=jihe.end();d++)
    {
        cout<<(*d)<<endl;
    }
    set<int>::iterator c;
    c=jihe.begin();
    cout<<(*c)<<endl;
    cout<<jihe.size()<<endl;
    cout<<jihe.max_size()<<endl;
    set<char>ji;
    cout<<ji.max_size()<<endl;
    cout<<"空则返回1,非空返回0 "<<jihe.empty()<<endl;
    jihe.clear();
    cout<<"空则返回1,非空返回0 "<<jihe.empty()<<endl;
    cout<<jihe.count(5)<<endl;
    return 0;
}

全部评论

相关推荐

02-07 10:52
复旦大学 Java
混子不想混:非常能理解,感觉他们就靠着入行早,打压新人一样。我这个公司也是,天天干的累死累活,然后绩效打C,合着让新人被绩效,像是年底攒棺材本一样。总是打击之后,还会让人开始自我怀疑,是不是我努力的还不够,实际上并不是,就是他们不做人,故意打压新人。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务