-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrefsem1.cpp
More file actions
42 lines (33 loc) · 753 Bytes
/
refsem1.cpp
File metadata and controls
42 lines (33 loc) · 753 Bytes
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
#include <iostream>
#include <list>
#include <deque>
#include <algorithm>
#include <sequtils.h>
#include <countptr.h>
using namespace std;
ostream& operator<<(ostream& os, const CountedPtr<int>& elem) {
os << *elem << ' ';
return os;
}
int main(int argc, char *argv[])
{
static int v[]= {3,5,9,1,6,4};
typedef CountedPtr<int> IntPtr;
deque<IntPtr> col1;
list<IntPtr> col2;
for (int i =0 ; i < (sizeof(v) / sizeof(v[0])); ++i) {
IntPtr ptr(new int(v[i]));
col1.push_back(ptr);
col2.push_front(ptr);
}
print_seq(col1);
print_seq(col2);
// square 3rd element
*col1[2] *= *col1[2];
// negate first element
(**col1.begin()) *= -1;
(**col2.begin()) = 0;
print_seq(col1);
print_seq(col2);
return 0;
}