-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstbiblio.cc
73 lines (51 loc) · 1.42 KB
/
stbiblio.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <list>
using namespace std;
void print_list(list<int>& l1){
for(list<int>::iterator it = l1.begin(); it!=l1.end(); ++it) {
//definirame iterator za spisuk ot celi chisla, vurvi dokato ne minem do edno sled posledniq - tam spira, obhojdat se vs elementi i trqq da gi outnem, znaeiki che moderira ukazatel:
cout<< *it << endl;
}
}
int main()
{
list<int> l1;
cout <<"empty" << l1.empty() << endl;
cout <<"size" << l1.size() <<endl;
l1.push_front(-1);
l1.push_back(1);
l1.push_front(-2);
l1.push_back(2);
cout <<"empty" << l1.empty() << endl;
cout <<"size" << l1.size() << endl;
cout << l1.back() << endl;
cout << l1.front() << endl;
//front i back ni vrushtat stoinostta bez da iztrivat; push_back dobavq nov element v kraq, a push_front - v nachaloto;
print_list(l1);
for(auto it = l1.begin(); it != l1.end(); ++it){
cout << *it << " ";
//auto kazva da se izvede sam tipa
}
cout << endl;
l1.insert(l1.begin(), -10);
l1.insert(l1, end(), 10);
print_list(l1);
auto it=l1.begin();
it++;
it++;
it++;
it = l1.insert(it, 0);
print_list(l1);
l1.erase(it);
print_list(l1);
l1.erase(l1.begin(), l1.end());
cout<< "size" << l1.size() << endl;
list<int> l2(10);
print_list(l2);
list<int>l3(10, -1);
print_list(13);
int a[] = {0,1,2,3,4,5,6,7,8,9};
list<int> l4(a, a+10);
return 0;
//insert vmukva element predi elementa kum koito e nasochen iteratora
}