aboutsummaryrefslogtreecommitdiff
path: root/Lab1
diff options
context:
space:
mode:
authorYana Blashchishina <[email protected]>2024-02-24 23:10:49 -0800
committerYana Blashchishina <[email protected]>2024-02-24 23:10:49 -0800
commit77a0ab94621c86baa2e7c080157532372e26e757 (patch)
tree6b1aca22b4a6087f5aa558e3a927fb4c5264f4df /Lab1
parentinit (diff)
downloadlab-01-yanablash-77a0ab94621c86baa2e7c080157532372e26e757.tar.xz
lab-01-yanablash-77a0ab94621c86baa2e7c080157532372e26e757.zip
part 1 done
Diffstat (limited to 'Lab1')
-rw-r--r--Lab1/Lab1/Lab1.vcxproj4
-rw-r--r--Lab1/Lab1/Lab1.vcxproj.filters8
-rw-r--r--Lab1/Lab1/helpers.cpp40
-rw-r--r--Lab1/Lab1/helpers.h19
-rw-r--r--Lab1/Lab1/main.cpp63
5 files changed, 133 insertions, 1 deletions
diff --git a/Lab1/Lab1/Lab1.vcxproj b/Lab1/Lab1/Lab1.vcxproj
index 6e51b98..1a02955 100644
--- a/Lab1/Lab1/Lab1.vcxproj
+++ b/Lab1/Lab1/Lab1.vcxproj
@@ -127,8 +127,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="helpers.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="helpers.h" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/Lab1/Lab1/Lab1.vcxproj.filters b/Lab1/Lab1/Lab1.vcxproj.filters
index ce0c35c..28d6576 100644
--- a/Lab1/Lab1/Lab1.vcxproj.filters
+++ b/Lab1/Lab1/Lab1.vcxproj.filters
@@ -18,5 +18,13 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="helpers.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="helpers.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Lab1/Lab1/helpers.cpp b/Lab1/Lab1/helpers.cpp
new file mode 100644
index 0000000..8ceff48
--- /dev/null
+++ b/Lab1/Lab1/helpers.cpp
@@ -0,0 +1,40 @@
+#include "helpers.h"
+#include <iostream>
+
+using std::endl;
+using std::cout;
+
+
+void Print(const int(&cArray)[SIZE])
+{
+
+ for (auto i : cArray)
+ {
+ cout << i << endl;
+
+ }
+}
+
+void Print(const std::array<int, SIZE>& stdArray)
+{
+ for (auto i = 0u; i < stdArray.size(); i++)
+ {
+ cout << stdArray[i] << endl;
+
+ }
+}
+
+void Print(const std::vector<int>& myVector)
+{
+ for (auto i : myVector)
+ {
+ cout << i << endl;
+ }
+}
+
+void Print(const std::list<int>& myList)
+{
+ for (auto const& i : myList) {
+ cout << i << endl;
+ }
+} \ No newline at end of file
diff --git a/Lab1/Lab1/helpers.h b/Lab1/Lab1/helpers.h
new file mode 100644
index 0000000..4c08c11
--- /dev/null
+++ b/Lab1/Lab1/helpers.h
@@ -0,0 +1,19 @@
+#ifndef CONTAINER_HELPERS_H
+#define CONTAINER_HELPERS_H
+
+#include <array>
+#include <vector>
+#include <list>
+
+constexpr int SIZE = 12000;
+
+void Print(const int(&cArray)[SIZE]);
+
+void Print(const std::array<int, SIZE>& stdArray);
+
+void Print(const std::vector<int>& myVector);
+
+void Print(const std::list<int>& myList);
+
+
+#endif \ No newline at end of file
diff --git a/Lab1/Lab1/main.cpp b/Lab1/Lab1/main.cpp
index 24e3ef1..24072a8 100644
--- a/Lab1/Lab1/main.cpp
+++ b/Lab1/Lab1/main.cpp
@@ -3,18 +3,79 @@
// Class: CST116
// Assignment: Lab 1
+
+#include "helpers.h"
#include <iostream>
-int main() {
+using std::array;
+using std::vector;
+using std::list;
+
+
+
+void Create_CArray()
+{
+ int cArray[SIZE]{};
+
+ for (int i = 0; i < SIZE; i++)
+ {
+ cArray[i] = i;
+ }
+
+ Print(cArray);
+
+
+}
+void Create_StdArray()
+{
+ array<int, SIZE> stdArray = { };
+ for (int i = 0; i < SIZE; i++)
+ {
+ stdArray[i] = i;
+ }
+ Print(stdArray);
+}
+void Create_Vector()
+{
+ vector<int> myVector;
+ myVector.reserve(SIZE);
+ for (auto i = 0; i < SIZE; i++)
+ {
+ myVector.push_back(static_cast<int>(i));
+
+ }
+
+ Print(myVector);
+
+}
+
+void Create_List()
+{
+ list<int>myList{};
+
+ for (int i = 0; i < SIZE; i++)
+ {
+ myList.push_back(i);
+ }
+
+ Print(myList);
+
+}
+
+int main() {
+ //Create_CArray();
+ //Create_StdArray();
+ //Create_Vector();
+ //Create_List();
return 0;
} \ No newline at end of file