1 2 3 4 5
#include<bits/stdc++.h> using namespace std; int main(){ //定义长度为0的set //set<int> s; int a[]={5,1,3,1,2,4}; //利用数组初始化 set set<int> s(a,a+6); set<int>::iterator it; for(it=s.begin();it != s.end();it++){ cout<<*it<<" "; } cout<<endl; return 0; }