diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2022-11-02 14:15:24 +0330 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2022-11-02 14:15:24 +0330 |
| commit | 0c702901ccc86d908ce0bb77de5698f555b3c958 (patch) | |
| tree | 4ccf650bbc60ee55e531a326ae682cac9b4e74bf /challenge-189/deadmarshal/cpp/ch-1.cpp | |
| parent | 51c585599f0d5a08899e0380f216a15be14b1167 (diff) | |
| download | perlweeklychallenge-club-0c702901ccc86d908ce0bb77de5698f555b3c958.tar.gz perlweeklychallenge-club-0c702901ccc86d908ce0bb77de5698f555b3c958.tar.bz2 perlweeklychallenge-club-0c702901ccc86d908ce0bb77de5698f555b3c958.zip | |
challenge189
Diffstat (limited to 'challenge-189/deadmarshal/cpp/ch-1.cpp')
| -rw-r--r-- | challenge-189/deadmarshal/cpp/ch-1.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-189/deadmarshal/cpp/ch-1.cpp b/challenge-189/deadmarshal/cpp/ch-1.cpp new file mode 100644 index 0000000000..46aa62cb47 --- /dev/null +++ b/challenge-189/deadmarshal/cpp/ch-1.cpp @@ -0,0 +1,23 @@ +#include<iostream> +#include<algorithm> + +char greater_character(std::vector<char> vec, char target) +{ + std::sort(vec.begin(), vec.end()); + for(std::size_t i = 0; i < vec.size(); ++i) + { + if(vec[i] > target) return vec[i]; + } + return target; +} + +int main() +{ + std::cout << greater_character({'e','m','u','g'}, 'b') << '\n'; + std::cout << greater_character({'d','c','e','f'}, 'a') << '\n'; + std::cout << greater_character({'j','a','r'}, 'o') << '\n'; + std::cout << greater_character({'d','c','a','f'}, 'a') << '\n'; + std::cout << greater_character({'t','g','a','l'}, 'v') << '\n'; + return 0; +} + |
