From 3e528a8fb023c20355d619bee624d261922274d4 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 14 Sep 2020 08:57:38 +0100 Subject: - Moved c++ solution to the correct folder. --- challenge-078/ash/cpp/ch-1.cpp | 30 ++++++++++++++++++++++++++++++ challenge-078/ash/raku/ch-1.cpp | 30 ------------------------------ 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 challenge-078/ash/cpp/ch-1.cpp delete mode 100644 challenge-078/ash/raku/ch-1.cpp diff --git a/challenge-078/ash/cpp/ch-1.cpp b/challenge-078/ash/cpp/ch-1.cpp new file mode 100644 index 0000000000..875dc4a005 --- /dev/null +++ b/challenge-078/ash/cpp/ch-1.cpp @@ -0,0 +1,30 @@ +/* + Task 1 from + https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/ + + Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/ + + Compile as: + $ g++ -std=c++17 ch-1.cpp +*/ + +#include +#include + +using namespace std; + +int main() { + vector a = {9, 10, 7, 5, 6, 1}; + + auto max = a.back(); + vector leaders = {max}; + for (auto i = a.rbegin(); i != a.rend(); i++) { + if (*i > max) { + max = *i; + leaders.push_back(max); + } + } + + for (auto i = leaders.rbegin(); i != leaders.rend(); i++) + cout << *i << endl; +} diff --git a/challenge-078/ash/raku/ch-1.cpp b/challenge-078/ash/raku/ch-1.cpp deleted file mode 100644 index 875dc4a005..0000000000 --- a/challenge-078/ash/raku/ch-1.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - Task 1 from - https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/ - - Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/ - - Compile as: - $ g++ -std=c++17 ch-1.cpp -*/ - -#include -#include - -using namespace std; - -int main() { - vector a = {9, 10, 7, 5, 6, 1}; - - auto max = a.back(); - vector leaders = {max}; - for (auto i = a.rbegin(); i != a.rend(); i++) { - if (*i > max) { - max = *i; - leaders.push_back(max); - } - } - - for (auto i = leaders.rbegin(); i != leaders.rend(); i++) - cout << *i << endl; -} -- cgit