aboutsummaryrefslogtreecommitdiff
path: root/Project1
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-10 13:37:34 -0800
committerConnor McDowell <[email protected]>2024-02-10 13:37:34 -0800
commita6cbf2ae0d6d953a2e9da7f069c184853fca3cc3 (patch)
tree7920404119bc2c64a0699afcc23fa5a5f3b71651 /Project1
parenti dunno whats wrong its saying there should be a ; where there shouldnt and e... (diff)
downloadlab-01-connormcdowell275-a6cbf2ae0d6d953a2e9da7f069c184853fca3cc3.tar.xz
lab-01-connormcdowell275-a6cbf2ae0d6d953a2e9da7f069c184853fca3cc3.zip
errors fixed, vectors and lists made, still working on lists
Diffstat (limited to 'Project1')
-rw-r--r--Project1/helper.cpp30
-rw-r--r--Project1/helper.h13
-rw-r--r--Project1/program.cpp57
3 files changed, 85 insertions, 15 deletions
diff --git a/Project1/helper.cpp b/Project1/helper.cpp
index 85b6ac4..de05926 100644
--- a/Project1/helper.cpp
+++ b/Project1/helper.cpp
@@ -1,8 +1,14 @@
+#include "helper.h"
#include <iostream>
#include <array>
#include <vector>
-#include "helper.h"
+#include <list>
+using std::cin;
+using std::cout;
+using std::endl;
+using std::array;
+using std::vector;
void Print(int(&cArray)[SIZE])
@@ -13,10 +19,28 @@ void Print(int(&cArray)[SIZE])
}
}
-void Print_std(std::array<int, SIZE> stdArray[])
+void Print(const std::array<int, SIZE> &stdArray)
{
- for (auto i = 0u; i < stdArray->size(); i++)
+ for (auto i = 0u; i < stdArray.size(); i++)
{
std::cout << i << std::endl;
}
}
+
+void Print(const std::vector<int> &myVector)
+{
+ for (auto& i : myVector)
+ {
+ std::cout << i << std::endl;
+ }
+
+}
+
+void Print(const std::list<int>& myList)
+{
+ for (auto& i : myList)
+ {
+ std::cout << i << std::endl;
+ }
+
+} \ No newline at end of file
diff --git a/Project1/helper.h b/Project1/helper.h
index 0d2f876..7fb2159 100644
--- a/Project1/helper.h
+++ b/Project1/helper.h
@@ -1,13 +1,22 @@
#ifndef HELPER
#define HELPER
+#include <iostream>
#include <array>
#include <vector>
+#include <list>
+
+using std::array;
+using std::vector;
constexpr int SIZE = 12000;
-void Print(const int(&cArray)[SIZE]);
+void Print(int(&cArray)[SIZE]);
+
+void Print(const std::array<int, SIZE> &stdArray);
+
+void Print(const std::vector<int>& myVector);
-void Print_std(std::array<int, SIZE> stdArray[])
+void Print(const std::list<int>& myList);
#endif HELPER
diff --git a/Project1/program.cpp b/Project1/program.cpp
index ddd5d58..29033dc 100644
--- a/Project1/program.cpp
+++ b/Project1/program.cpp
@@ -3,36 +3,73 @@
// class: CST116
// Reason: lab #1
+#include "helper.h"
#include <iostream>
#include <array>
#include <vector>
-#include "helper.h"
+#include <list>
+using std::cin;
+using std::cout;
+using std::endl;
+using std::array;
+using std::vector;
+using std::list;
-int main()
+void createArray()
{
int cArray[SIZE];
- for(int i = 0; i < SIZE; i++)
+ for (int i = 0; i < SIZE; i++)
{
cArray[i] = i;
}
+ Print(cArray);
+}
- int t;
-
-
+void createstdArray()
+{
std::array<int, SIZE> stdArray = { };
- for(int t = 0; t < SIZE; t++)
+ for (int i = 0; i < SIZE; i++)
{
- stdArray[t] = t;
+ stdArray[i] = i;
}
- Print_std(&stdArray);
+ Print(stdArray);
+}
- /*Print(cArray);*/
+void createVector()
+{
+ std::vector<int> myVector;
+ myVector.reserve(SIZE);
+ for (auto i = 0; i < SIZE; i++)
+ {
+ myVector.push_back(i);
+ }
+ Print(myVector);
+}
+
+void Create_list()
+{
+ int i, t;
+ std::list<int> myList (SIZE, i);
+ for (auto i = 0; i < SIZE; i++)
+ {
+ myList.push_back(i);
+ }
+ Print(myList);
+}
+
+int main()
+{
+ //createArray();
+ //createstdArray();
+ //createVector();
+ Create_list();
+
return 0;