aboutsummaryrefslogtreecommitdiff
path: root/challenge-148/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-01-19 10:24:25 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-01-19 10:24:25 +0000
commitc0adc3a91ca7f5ba8d840c6897a946c184db65da (patch)
treed5b6c2b697d1c355d90c52c575390c2d28764f89 /challenge-148/ulrich-rieke/cpp/ch-1.cpp
parentd7ce9a5763d84747ca603445b1ceab15b64498e3 (diff)
downloadperlweeklychallenge-club-c0adc3a91ca7f5ba8d840c6897a946c184db65da.tar.gz
perlweeklychallenge-club-c0adc3a91ca7f5ba8d840c6897a946c184db65da.tar.bz2
perlweeklychallenge-club-c0adc3a91ca7f5ba8d840c6897a946c184db65da.zip
- Added solutions by Ulrich Rieke.
Diffstat (limited to 'challenge-148/ulrich-rieke/cpp/ch-1.cpp')
-rw-r--r--challenge-148/ulrich-rieke/cpp/ch-1.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-148/ulrich-rieke/cpp/ch-1.cpp b/challenge-148/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..5d52ffcff9
--- /dev/null
+++ b/challenge-148/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,31 @@
+#include <iostream>
+#include <string>
+#include <array>
+#include <vector>
+
+int main( ) {
+ std::array<std::string, 9> smallNumbers { "one" , "two" , "three" , "four" ,
+ "five" , "six" , "seven" , "eight" , "nine" } ;
+ std::array<std::string, 10> teens { "ten" , "twenty" , "thirty" , "forty" ,
+ "fifty" , "sixty" , "seventy" , "eighty" , "ninety" , "hundred" } ;
+ std::vector<int> ebannumbers ;
+ for( int i = 0 ; i < 9 ; i++ ) {
+ if ( smallNumbers[ i ].find( 'e' ) == std::string::npos )
+ ebannumbers.push_back( i + 1 ) ;
+ }
+ for( int i = 0 ; i < 10 ; i++ ) {
+ if ( teens[ i ].find( 'e' ) == std::string::npos ) {
+ ebannumbers.push_back( (i + 1 ) * 10 ) ;
+ for ( int j = 0 ; j < 9 ; j++ ) {
+ if ( smallNumbers[j].find( 'e' ) == std::string::npos ) {
+ ebannumbers.push_back( (i + 1 ) * 10 + j + 1 ) ;
+ }
+ }
+ }
+ }
+ for ( int num : ebannumbers ) {
+ std::cout << num << " " ;
+ }
+ std::cout << std::endl ;
+ return 0 ;
+}