You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
508 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<bits/stdc++.h>
using namespace std;
int main() {
set<int> s;
s.insert(1);
s.insert(2);
s.insert(3);
s.insert(1);
cout<<"set 的 size 值为 "<<s.size()<<endl;
cout<<"set 的 maxsize的值为 "<<s.max_size()<<endl;
cout<<"set 中的第一个元素是 "<<*s.begin()<<endl;
cout<<"set 中的最后一个元素是:"<<*s.end()<<endl;
s.clear();
if(s.empty()) {
cout<<"set 为空 "<<endl;
}
cout<<"set 的 size 值为 "<<s.size()<<endl;
cout<<"set 的 maxsize的值为 "<<s.max_size()<<endl;
return 0;
}