diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2023-07-14 08:12:41 +0330 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2023-07-14 08:12:41 +0330 |
| commit | fcd352576e64dd7156578f626b5e91f9dbd41438 (patch) | |
| tree | 597ec55003091e4849ce00ae5be8574bb2fbd7d3 /challenge-225/deadmarshal/cpp/ch-1.cpp | |
| parent | f4d2ab78a5ea8cb69132cfee6c46fce3b98d2a10 (diff) | |
| download | perlweeklychallenge-club-fcd352576e64dd7156578f626b5e91f9dbd41438.tar.gz perlweeklychallenge-club-fcd352576e64dd7156578f626b5e91f9dbd41438.tar.bz2 perlweeklychallenge-club-fcd352576e64dd7156578f626b5e91f9dbd41438.zip | |
TWC225
Diffstat (limited to 'challenge-225/deadmarshal/cpp/ch-1.cpp')
| -rw-r--r-- | challenge-225/deadmarshal/cpp/ch-1.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-225/deadmarshal/cpp/ch-1.cpp b/challenge-225/deadmarshal/cpp/ch-1.cpp new file mode 100644 index 0000000000..17fb182b49 --- /dev/null +++ b/challenge-225/deadmarshal/cpp/ch-1.cpp @@ -0,0 +1,31 @@ +#include<iostream> +#include<vector> +#include<cctype> + +std::size_t max_words(const std::vector<std::string> &vec) +{ + size_t count{},max{}; + for(const auto & s : vec) + { + for(const auto &c : s) if(isspace(c)) count++; + if(max < count) max = count; + count = 0; + } + return max+1; +} + +int main(int argc, char **argv) +{ + std::vector<std::string> + vec{"Perl and Raku belong to the same family.", + "I love perl.", + "The Perl and Raku Conference."}; + std::vector<std::string> + vec2{"The Weekly Challenge.", + "Python is the most popular guest language.", + "Team PWC has over 300 members."}; + std::cout << max_words(vec) << '\n'; + std::cout << max_words(vec2) << '\n'; + return 0; +} + |
