diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2024-01-02 02:29:50 -0500 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2024-01-02 02:29:50 -0500 |
| commit | 754a0f9cce2dc07a97609f2b8bc642dfee61930f (patch) | |
| tree | 7bd79339617fc14720b3bc79d52453563b6e06e9 /challenge-250/deadmarshal/cpp/ch-1.cpp | |
| parent | 5f38c976cae9103ec02e413224d047d8b149956d (diff) | |
| download | perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.tar.gz perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.tar.bz2 perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.zip | |
TWC250
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; +} + |
