From 428d857359b5d8b639ca41b03ca8fc8b3d143a50 Mon Sep 17 00:00:00 2001 From: Oskar Date: Sat, 12 Oct 2024 15:06:05 +0200 Subject: more --- 9p21.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 9p21.cpp (limited to '9p21.cpp') 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 +#include +#include + +/* + * + * 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 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; +} -- cgit v1.2.3