summaryrefslogtreecommitdiff
path: root/9p21.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-10-12 15:06:05 +0200
committerOskar <[email protected]>2024-10-12 15:06:05 +0200
commit428d857359b5d8b639ca41b03ca8fc8b3d143a50 (patch)
tree6c6291c2404386673ef6cd65ad435374e519d35b /9p21.cpp
parentf46aaa42631113d83bc211a9db4f85ef68afdc92 (diff)
more
Diffstat (limited to '9p21.cpp')
-rw-r--r--9p21.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/9p21.cpp b/9p21.cpp
new file mode 100644
index 0000000..be101b9
--- /dev/null
+++ b/9p21.cpp
@@ -0,0 +1,27 @@
+#include <iostream>
+#include <list>
+#include <vector>
+
+/*
+ *
+ * 9.21
+ *
+ * It's the same thing. Vector does not have push_front so this would be necessary.
+ * It's an expensive operation to do this so it woul be best to use a deque
+ */
+
+int main () {
+
+ std::string word;
+ std::vector<std::string> lst;
+ auto iter = lst.begin();
+ while (std::cin >> word) {
+ iter = lst.insert(iter, word); // same as calling push_front
+ }
+
+ for(auto &a : lst) {
+ std::cout << a << std::endl;
+ }
+
+ return 0;
+}