clear是成员函数 @[Dcchen](/user/1012241)
by CNCAGN @ 2023-11-18 17:56:42
所以应该怎么调用呢?@[CNCAGN](/user/65161)
by Dcchen @ 2023-11-18 17:57:45
`s.clear()`。
by Libingyue2011 @ 2023-11-18 18:03:12
```
#include<set>
#include<iostream>
using namespace std;
set<int> s;
int T,n,x;
int main(){
ios::sync_with_stdio(0);
cin>>T;
while(T--){
cin>>n;
while(n--){
cin>>x;
s.insert(x);
}
for(auto it:s)cout<<it<<" ";
s.clear();
}
return 0;
}
```
还是报错
@[Libingyue2011](/user/886055)
by Dcchen @ 2023-11-18 18:08:48
啊不!是我的编译器的题。
感谢二位!!
@[Libingyue2011](/user/886055)
@[CNCAGN](/user/65161)
by Dcchen @ 2023-11-18 18:10:42