-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab_solution_02.cpp
46 lines (39 loc) · 900 Bytes
/
Lab_solution_02.cpp
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
#include <iostream>
#include <array>
#include <vector>
using namespace std;
int main()
{
cout << "--- Create a C-Style Array ---" << endl;
int cStyleArr[4] = {1, 2, 3, 4};
int i;
for(i=0; i<4; i++)
{
cout << "cStyleArr[" << i << "] = " << cStyleArr[i] << endl;
}
cout << "--- Create an std::array ---" << endl;
array<int,4> array1 {1,2,3,4};
cout << "array1 = { ";
for(int n: array1)
{
cout << n << ",";
}
cout << "}; \n";
cout << "--- Create an std::vector ---" << endl;
vector<int> vector1 {1,2,3,4};
cout << "vector1 = { ";
for(int n: vector1)
{
cout << n << ",";
}
cout << "}; \n";
cout << "Add element at the end : 9" << endl;
vector1.push_back(9);
cout << "vector1 = { ";
for(int n: vector1)
{
cout << n << ",";
}
cout << "}; \n";
return 0;
}