aboutsummaryrefslogtreecommitdiff
path: root/challenge-140/ulrich-rieke/cpp/ch-2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-140/ulrich-rieke/cpp/ch-2.cpp')
-rw-r--r--challenge-140/ulrich-rieke/cpp/ch-2.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-140/ulrich-rieke/cpp/ch-2.cpp b/challenge-140/ulrich-rieke/cpp/ch-2.cpp
new file mode 100644
index 0000000000..a2e0e6eafb
--- /dev/null
+++ b/challenge-140/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,26 @@
+#include <vector>
+#include <iostream>
+#include <algorithm>
+
+int main( ) {
+ std::cout << "Enter an positive integer!\n" ;
+ int i ;
+ std::cin >> i ;
+ std::cout << "\nanother positive integer!\n" ;
+ int j ;
+ std::cin >> j ;
+ std::cout << "\nanother positive integer!\n" ;
+ int k ;
+ std::cin >> k ;
+ std::vector<int> allNumbers ;
+ for ( int n = 1 ; n < j + 1 ; n++ )
+ allNumbers.push_back( n ) ;
+ for ( int mult = 2 ; mult < i + 1 ; mult++ ) {
+ for ( int n = 1 ; n < j + 1 ; n++ ) {
+ allNumbers.push_back( n * mult ) ;
+ }
+ }
+ std::sort( allNumbers.begin( ) , allNumbers.end( ) ) ;
+ std::cout << allNumbers[ k - 1 ] << std::endl ;
+ return 0 ;
+}