The key is to declare iterator variables. The traversal method is similar to an array. You can use either a while loop or a for loop, but the conditional operator cannot use <while using a for loop! = Make judgments and pay special attention to pointer operators .
Code:
#include<iostream>
#include<set>
using namespace std;
set<int>all;
int main()
{
//生成待处理的数据
for(int i=0;i<100;i++)
all.insert(i);
//遍历set,用迭代器类型
for(set<int>::iterator i=all.begin();i!=all.end();i++)
cout<<*i<<endl; //注意指针运算符
return 0;
}