1#include <vector>
2
3int main() {
4 std::vector<int> v;
5 v.push_back(10); // v = [10];
6 v.push_back(20); // v = [10, 20];
7
8 v.pop_back(); // v = [10];
9 v.push_back(30); // v = [10, 30];
10
11 auto it = v.begin();
12 int x = *it; // x = 10;
13 ++it;
14 int y = *it; // y = 30
15 ++it;
16 bool is_end = it == v.end(); // is_end = true
17
18 return 0;
19}
1#include <iostream>
2#include<vector>
3#include<algorithm>
4
5using namespace std;
6
7int main()
8{
9 int n;
10 cin>>n;
11 vector<int>vec(n);
12 for(int i=0;i<n;i++)
13 {
14 cin>>vec[i];
15 }
16 cout<<"----------"<<endl;
17 for(int i=0;i<n;i++)
18 {
19 cout<<vec[i]<<" ";
20 }
21 vec.push_back(100);
22 vec.push_back(200);
23 cout<<endl;
24 auto it=vec.begin();
25 vec.insert(it,3,1000);
26 for(vector<int>::iterator it1=vec.begin();it1!=vec.end();it1++)
27 {
28 cout<<*it1<<" ";
29 }
30 cout<<endl;
31 vector<int>vec2;
32 vec2.push_back(15);
33 vec2.push_back(25);
34 vec2.push_back(35);
35 vec.insert(it,vec2.begin(),vec2.end());
36 for(vector<int>::iterator it1=vec.begin();it1!=vec.end();it1++)
37 {
38 cout<<*it1<<" ";
39 }
40 cout<<endl;
41 vec.pop_back();
42 vec.pop_back();
43 for(vector<int>::iterator it1=vec.begin();it1!=vec.end();it1++)
44 {
45 cout<<*it1<<" ";
46 }
47 cout<<endl;
48 int k;
49 cin>>k;
50 cout<<endl;
51 vector<int>::iterator its=vec.begin()+k-1;
52 int s=vec.size();
53 cout<<s<<endl;
54 vec.erase(its);
55 for(vector<int>::iterator it1=vec.begin();it1!=vec.end();it1++)
56 {
57 cout<<*it1<<" ";
58 }
59
60
61 return 0;
62}
63