aboutsummaryrefslogtreecommitdiff
path: root/challenge-103/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-103/ulrich-rieke/cpp/ch-1.cpp')
-rw-r--r--challenge-103/ulrich-rieke/cpp/ch-1.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-103/ulrich-rieke/cpp/ch-1.cpp b/challenge-103/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..28bbd58011
--- /dev/null
+++ b/challenge-103/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,18 @@
+#include <vector>
+#include <string>
+#include <iostream>
+#include <cstdlib>
+
+int main( int argc, char * argv[] ) {
+ int year = std::atoi( argv[1] ) ;
+ std::vector<std::string> animals {"Rat" , "Ox" , "Tiger" , "Rabbit" , "Dragon" , "Snake",
+ "Horse" , "Goat" , "Monkey" , "Rooster", "Dog" , "Pig" } ;
+ std::vector<std::string> elements {"Wood" , "Fire" , "Earth" , "Metal" , "Water" } ;
+ int elementlen = elements.size( ) ;
+ int animallen = animals.size( ) ;
+ int yeardiff = year - 1924 ;
+ int animalindex = yeardiff % animallen ;
+ int elementindex = ( yeardiff / 2 ) % elementlen ;
+ std::cout << elements[ elementindex ] << " " << animals[ animalindex ] << std::endl ;
+ return 0 ;
+}