```c++
#include <bits/stdc++.h>
using namespace std;
set s;
int main()
{
int x;
cin>>x;
s.insert(x);
for(auto v: s) cout<<v<<endl;
return 0;
}
```for语句报错了》。。。。。
```c++
#include <bits/stdc++.h>
using namespace std;
set s;
int main()
{
int x;
cin>>x;
s.insert(x);
for(auto v: s) cout<<v<<endl;
return 0;
}
```for语句报错了》。。。。。
range-for是C++11新语法,你得确定你的编译器支持C++11,并打开C++11选项,比如:
#include <iostream>
#include <set>
int main()
{
std::set<int> s = {1, 2, 3, 3, 4};
for (auto v : s)
std::cout << v << ' ';
std::cout << std::endl;
return 0;
}
$ g++ -Wall -std=c++11 main.cpp
$ ./a.out
1 2 3 4