From 77b344e13eae4b4439f96a8d062151da03bf8263 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 1 Nov 2024 10:44:53 +0100 Subject: been a while, took a break i guess --- 9p34.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to '9p34.cpp') diff --git a/9p34.cpp b/9p34.cpp index 58d5fbf..a8317ef 100644 --- a/9p34.cpp +++ b/9p34.cpp @@ -1,12 +1,26 @@ #include +#include /* * - * Description + * 9.34 * * */ int main () { + + // Prediction: The program will get stuck on the first odd value and keep inserting it indefinitely + std::vector vi = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + auto iter = vi.begin(); + while (iter != vi.end()) { + if (*iter % 2) { // when it's odd + iter = vi.insert(iter, *iter); // insert copy of *iter before iter, return iterator to inserted value + std::cout << "inserted value: " << *iter << "\n"; + } + + ++iter; // go one step forwards + } + return 0; } -- cgit v1.2.3