diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2023-03-11 17:03:30 +0330 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2023-03-11 17:03:30 +0330 |
| commit | 2a9c7f49feef90d54aa477b5a80c2979a548cb81 (patch) | |
| tree | 5fb8608f2180ff313d56efab79e51001768b2494 /challenge-207/deadmarshal/cpp/ch-2.cpp | |
| parent | 1f9e919800ebc28992c10467f2e9a2d1afe90169 (diff) | |
| download | perlweeklychallenge-club-2a9c7f49feef90d54aa477b5a80c2979a548cb81.tar.gz perlweeklychallenge-club-2a9c7f49feef90d54aa477b5a80c2979a548cb81.tar.bz2 perlweeklychallenge-club-2a9c7f49feef90d54aa477b5a80c2979a548cb81.zip | |
TWC207
Diffstat (limited to 'challenge-207/deadmarshal/cpp/ch-2.cpp')
| -rw-r--r-- | challenge-207/deadmarshal/cpp/ch-2.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-207/deadmarshal/cpp/ch-2.cpp b/challenge-207/deadmarshal/cpp/ch-2.cpp new file mode 100644 index 0000000000..6af3160443 --- /dev/null +++ b/challenge-207/deadmarshal/cpp/ch-2.cpp @@ -0,0 +1,22 @@ +#include<iostream> +#include<vector> + +int h_index(const std::vector<int> &vec) +{ + int ret{}; + for(int i = 0; i < vec.size(); ++i) + if(i >= vec[i]) + { + ret = i; + break; + } + return ret; +} + +int main() +{ + std::cout << h_index({10,8,5,4,3}) << '\n'; + std::cout << h_index({25,8,5,3,3}) << '\n'; + return 0; +} + |
