summaryrefslogtreecommitdiff
path: root/9p34.cpp
diff options
context:
space:
mode:
Diffstat (limited to '9p34.cpp')
-rw-r--r--9p34.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/9p34.cpp b/9p34.cpp
index 58d5fbf..a8317ef 100644
--- a/9p34.cpp
+++ b/9p34.cpp
@@ -1,12 +1,26 @@
#include <iostream>
+#include <vector>
/*
*
- * Description
+ * 9.34
*
*
*/
int main () {
+
+ // Prediction: The program will get stuck on the first odd value and keep inserting it indefinitely
+ std::vector<int> 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;
}