前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C++ set容器元素的插入与遍历

C++ set容器元素的插入与遍历

作者头像
用户7886150
修改2021-01-18 11:47:47
2.3K0
修改2021-01-18 11:47:47
举报
文章被收录于专栏:bit哲学院

参考链接: C++ 集合Set的遍历

int main(int argc, const char *argv[])

{    

    set<string> set_str;    

    string str;

    while(cin>>str)

        set_str.insert(str);

    set<string>::iterator iter=set_str.begin();

    while(iter!=set_str.end())

    {

        cout<<*iter<<endl;

        ++iter;

    }

    system("pause");

    return 0;

}/*

 123

 456

 789

 abc

 def

 hij

 ^Z

 123

 456

 789

 abc

 def

 hij

 请按任意键继续. . .

 */

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档