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;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 17:30
点赞 评论 收藏
分享
07-01 17:14
中北大学 Java
兄弟们是真是假
牛客46374834...:我在boss上投java岗从来没成功过
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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