diff options
Diffstat (limited to 'challenge-240/deadmarshal/cpp/ch-2.cpp')
| -rw-r--r-- | challenge-240/deadmarshal/cpp/ch-2.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-240/deadmarshal/cpp/ch-2.cpp b/challenge-240/deadmarshal/cpp/ch-2.cpp new file mode 100644 index 0000000000..cdc7ef28da --- /dev/null +++ b/challenge-240/deadmarshal/cpp/ch-2.cpp @@ -0,0 +1,22 @@ +#include<iostream> +#include<vector> + +template<typename T> +void build_array(const std::vector<T> &vec) +{ + std::vector<T> ret(vec.size(),0); + for(size_t i = 0; i < vec.size(); ++i) ret.at(i) = vec.at(vec.at(i)); + for(size_t i = 0; i < ret.size(); ++i) + std::cout << ret.at(i) << ' '; + std::cout << '\n'; +} + +int main() +{ + std::vector<int> vec1 = {0,2,1,5,3,4}; + std::vector<int> vec2 = {5,0,1,2,3,4}; + build_array<int>(vec1); + build_array<int>(vec2); + return 0; +} + |
