W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
#include <iostream>
#include <set>
using namespace std;
​
int main() {
  // 创建存储字符串的集合 cars
  set<string> cars = {"Volvo", "BMW", "Ford", "Tesla"};
​
  // 使用迭代器遍历集合
  for (auto it = cars.begin(); it != cars.end(); ++it) {
    cout << *it << "\n";
  }
  
  return 0;
}