aboutsummaryrefslogtreecommitdiff
path: root/Lab1
diff options
context:
space:
mode:
Diffstat (limited to 'Lab1')
-rw-r--r--Lab1/Lab1/helpers.cpp56
-rw-r--r--Lab1/Lab1/helpers.h10
-rw-r--r--Lab1/Lab1/main.cpp4
3 files changed, 70 insertions, 0 deletions
diff --git a/Lab1/Lab1/helpers.cpp b/Lab1/Lab1/helpers.cpp
index 8ceff48..8078276 100644
--- a/Lab1/Lab1/helpers.cpp
+++ b/Lab1/Lab1/helpers.cpp
@@ -37,4 +37,60 @@ void Print(const std::list<int>& myList)
for (auto const& i : myList) {
cout << i << endl;
}
+}
+
+
+void Fibonacci(int(&cArray)[SIZE])
+{
+ cArray[0] = 0;
+ cArray[1] = 1;
+
+ for (int i = 2; i < SIZE; ++i)
+ {
+ cArray[i] = cArray[i - 1] + cArray[i - 2];
+ }
+}
+
+
+
+void Fibonacci(std::array<int, SIZE>& stdArray)
+{
+ stdArray[0] = 0;
+ stdArray[1] = 1;
+
+ for (auto i = 2u; i < stdArray.size(); ++i)
+ {
+ stdArray[i] = stdArray[i - 1] + stdArray[i - 2];
+ }
+}
+
+
+
+void Fibonacci(std::vector<int>& myVector)
+{
+ myVector.resize(SIZE);
+
+ myVector[0] = 0;
+ myVector[1] = 1;
+
+ for (auto i = 2u; i < myVector.size(); ++i)
+ {
+ myVector[i] = myVector[i - 1] + myVector[i - 2];
+ }
+}
+
+
+
+void Fibonacci(std::list<int>& myList)
+{
+ myList.push_back(0);
+ myList.push_back(1);
+
+ auto it = myList.begin();
+
+ for (int i = 2; i < SIZE; ++i)
+ {
+ myList.push_back(*std::prev(it) + *it);
+ ++it;
+ }
} \ No newline at end of file
diff --git a/Lab1/Lab1/helpers.h b/Lab1/Lab1/helpers.h
index 4c08c11..d30b69b 100644
--- a/Lab1/Lab1/helpers.h
+++ b/Lab1/Lab1/helpers.h
@@ -16,4 +16,14 @@ void Print(const std::vector<int>& myVector);
void Print(const std::list<int>& myList);
+
+void Fibonacci(int(&cArray)[SIZE]);
+
+void Fibonacci(std::array<int, SIZE>& stdArray);
+
+void Fibonacci(std::vector<int>& myVector);
+
+void Fibonacci(std::list<int>& myList);
+
+
#endif \ No newline at end of file
diff --git a/Lab1/Lab1/main.cpp b/Lab1/Lab1/main.cpp
index 24072a8..59c488f 100644
--- a/Lab1/Lab1/main.cpp
+++ b/Lab1/Lab1/main.cpp
@@ -77,5 +77,9 @@ int main() {
//Create_List();
+
+
+
+
return 0;
} \ No newline at end of file