set 容器
来源:互联网 发布:淘宝代付可以用微信吗 编辑:程序博客网 时间:2024/05/16 07:27
//set 容器里面不可以有重复的元素//a 和 b 重复 == “a必须排在b前面” 和 “b必须排在前面”都不成立#include<iostream>#include<cstring>#include<set>using namespace std;int main(){ set<int> st; int a[10]={1,2,3,8,7,7,5,6,8,12}; for(int i = 0; i < 10; ++i) st.insert(a[i]); cout << st.size() <<endl; set<int>::iterator i; for(i = st.begin(); i != st.end(); ++i) cout << *i << " "; cout << endl; //输出: 1,2,3,5,6,7,8,12 //插入数据 pair< set<int>::iterator, bool >result = st.insert(2); if( ! result.second ) cout << *result.first << " already exists."; else cout << *result.first << " inserted." << endl; return 0;}/*pair< set<int>::iterator, bool>相当于struct{ set<int>::iterator first; bool second;};*/
0 0
- set容器
- set容器
- set容器
- 容器set
- set容器
- 容器set
- set 容器
- Set容器
- 容器Set
- set容器
- set 容器
- set容器
- set容器
- set容器
- set容器
- set容器
- set 容器
- set容器
- 二叉树的创建和基本操作(递归和非递归)
- multiset 的排序规则
- HTTP Status 500
- cropperjs在.vue中的使用
- FPGA:下一代机器人感知处理器
- set 容器
- 大白话讲解SVM
- [设计模式]责任链模式(Chain of Responsibility)
- Java关键字final、static使用总结
- 元组和字符串
- multimap容器
- 第十二周
- linux下多线程的使用 pthread_create()
- 学习opencv跟轮廓相关的