From 7d19e6afee0f7c1245e151ce673931ce8849f57e Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Sun, 20 Sep 2020 13:46:14 +0200 Subject: 078 in C++ and Python by ash --- challenge-078/ash/cpp/ch-2.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 challenge-078/ash/cpp/ch-2.cpp (limited to 'challenge-078/ash/cpp/ch-2.cpp') diff --git a/challenge-078/ash/cpp/ch-2.cpp b/challenge-078/ash/cpp/ch-2.cpp new file mode 100644 index 0000000000..c3133a8c06 --- /dev/null +++ b/challenge-078/ash/cpp/ch-2.cpp @@ -0,0 +1,32 @@ +/* + Task 2 from + https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/ + + Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/ + + Compile: + $ g++ -std=c++17 ch-2.cpp + + Output: + + $ ./a.out + 40 50 10 20 30 + 50 10 20 30 40 +*/ + +#include +#include + +using namespace std; + +int main() { + vector a = {10, 20, 30, 40, 50}; + vector b = {3, 4}; + + for (auto shift : b) { + for (auto pos = 0; pos != a.size(); pos++) { + cout << a[(pos + shift) % a.size()] << ' '; + } + cout << endl; + } +} -- cgit