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