首页 > 编程语言 > 详细

C++ set demo

时间:2019-07-18 01:58:22      阅读:100      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <set>
using namespace std;
void PrintS(set<int> s_int){
    cout<<"Print:";
    for (set<int>::iterator  it = s_int.begin(); it !=s_int.end() ; ++it) {
        cout<<*it<<" ";
    }
    cout<<endl;
}
int main() {
    std::cout << "Hello, World!" << std::endl;
    set<int> s_int{1,2,3,4,5,6,7};
    PrintS(s_int);
    s_int.erase(s_int.find(3));
    PrintS(s_int);
    s_int.insert(9);
    PrintS(s_int);
    s_int.insert(3);
    PrintS(s_int);
    return 0;
}

 

显示:

Print:1 2 3 4 5 6 7
Print:1 2 4 5 6 7
Print:1 2 4 5 6 7 9
Print:1 2 3 4 5 6 7 9

C++ set demo

原文:https://www.cnblogs.com/liuguoyao514257665/p/11204451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!