From 4affe13bb3e69ca19cea9a6790d1c9ffa5842515 Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Sat, 24 Feb 2024 16:31:01 -0800 Subject: std::lists are wack. --- Project1/helper.cpp | 14 +++++++++++++- Project1/program.cpp | 11 ++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Project1/helper.cpp b/Project1/helper.cpp index 48a04cd..c51a05e 100644 --- a/Project1/helper.cpp +++ b/Project1/helper.cpp @@ -40,7 +40,7 @@ void Print(const std::list& myList) { for (auto& i : myList) { - std::cout << i << std::endl; + cout << i << endl; } } @@ -94,4 +94,16 @@ void Fibonacci(std::vector& myVector) { cout << myVector[i] << " "; } +} + +void Fibonacci(std::list& myList) +{ + int y = 0; + cout << "enter the last element of the Fibonacci sequence you would like to see: "; + cin >> y; + for (auto& i : myList) + { + i = (i - 1) + (i - 2); + cout << i << " "; + } } \ No newline at end of file diff --git a/Project1/program.cpp b/Project1/program.cpp index 89ebc2e..222bddb 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -56,13 +56,14 @@ void createVector() void Create_list() { - int i; - std::list myList (SIZE, i); + int i = 0; + //std::list myList (SIZE, i); + list myList{}; for (auto i = 0; i < SIZE; i++) { myList.push_back(i); } - + Fibonacci(myList); //Print(myList); } @@ -70,8 +71,8 @@ int main() { //createArray(); //createstdArray(); - createVector(); - //Create_list(); + //createVector(); + Create_list(); return 0; -- cgit v1.2.3