- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- vector<int> v;
- v.push_back(5);
- v.push_back(1);
- v.push_back(3);
- v.push_back(8);
- v.push_back(9);
- cout<<v.size()<<endl;
- cout<<v.empty()<<endl;
- for(int i=0;i<v.size();i++)
- cout<<v[i]<<" ";
- cout<<endl;
- v.pop_back();
- v.erase(v.begin()+1);
- for(int i=0;i<v.size();i++)
- cout<<v[i]<<" ";
- cout<<endl;
- sort(v.begin(),v.end());
- for(int i:v)
- cout<<i<<" ";
- return 0;
- }
複製代碼 |