题解 | #迭代器遍历set#
迭代器遍历set
https://www.nowcoder.com/practice/7e57c0f7af86429db20c70053f23ea96
- 迭代器iterator正向遍历set集合元素
#include using namespace std; int main(){ sets; // write your code here...... for (int i = 0; i < 5; i++) { int temp = 0; cin >> temp; //插入元素在set集合中 s.insert(temp); } //开始遍历 for (set::iterator it = s.begin(); it != s.end(); it++) { cout << *it << " "; } return 0; }