#include "stdafx.h"
#include<set> //设置set容器必须要有set头文件;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
set<int> st;
st.insert(1);
st.insert(1);
st.insert(2);
st.insert(3);
for(set<int>::iterator it=st.begin();it!=st.end();it++)//不支持it<st.end() set只能通过迭代器访问
{
printf("%d ",*it);//除开vector和string之外的STL都不能使用*(it+i)
}
return 0;
}
set实例
最新推荐文章于 2023-06-14 18:14:26 发布