summaryrefslogtreecommitdiff
path: root/3p32.cpp
blob: 12b24b7780a7c2577f67afd06cfdb09ed0fd405f (plain)
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
#include <iostream>
#include <vector>

/*
 *
 * 3.32
 *
 * 
 */

int main () {

	constexpr size_t ArraySize = 10;
	int MyArray[ArraySize];
	int MyArray2[ArraySize];
	for(size_t Index = 0 ; Index != ArraySize ; ++Index) {
		MyArray[Index] = Index;
	}

	for(size_t Index = 0 ; Index != 10 ; ++Index) {
		MyArray2[Index] = MyArray[Index];
	}

	for(auto i : MyArray) {
		std::cout << i << std::endl;
	}

	std::cout << std::endl;
	for(auto i : MyArray2) {
		std::cout << i << std::endl;
	}
	
	std::cout << std::endl;

	// Vector version
	size_t VecSize = 10;
	std::vector<int> MyVec;
	std::vector<int> MyVec2;
	for(size_t Index = 0 ; Index != VecSize ; ++Index) {
		MyVec.push_back(Index);
	}

	MyVec2 = MyVec;
	// If we wanted to we could also initialize MyVec2 here instead of above
	// std::vector<int> MyVec2 = MyVec;
	
	for(auto i : MyVec) {
		std::cout << i << std::endl;
	}

	std::cout << std::endl;
	for(auto i : MyVec2) {
		std::cout << i << std::endl;
	}
	
	return 0;
}