From 754a0f9cce2dc07a97609f2b8bc642dfee61930f Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Tue, 2 Jan 2024 02:29:50 -0500 Subject: TWC250 --- challenge-250/deadmarshal/cpp/ch-1.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-250/deadmarshal/cpp/ch-1.cpp (limited to 'challenge-250/deadmarshal/cpp/ch-1.cpp') 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 +#include + +template +int smallest_index(const std::vector &vec) +{ + for(size_t i = 0; i < vec.size(); ++i) if(i % 10 == vec.at(i)) return i; + return -1; +} + +int main() +{ + std::vector vec1{0,1,2},vec2{4,3,2,1},vec3{1,2,3,4,5,6,7,8,9,0}; + std::cout << smallest_index(vec1) << '\n' + << smallest_index(vec2) << '\n' + << smallest_index(vec3) << '\n'; + return 0; +} + -- cgit