diff options
Diffstat (limited to 'challenge-150/ulrich-rieke/cpp/ch-1.cpp')
| -rw-r--r-- | challenge-150/ulrich-rieke/cpp/ch-1.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-150/ulrich-rieke/cpp/ch-1.cpp b/challenge-150/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..e2cb519390 --- /dev/null +++ b/challenge-150/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,23 @@ +#include <iostream> +#include <vector> +#include <string> + +int main( ) { + std::string firstnum ; + std::string secondnum ; + std::cout << "Enter a number string consisting of digits only!\n" ; + std::cin >> firstnum ; + std::cout << "Enter a second number string consisting of digits only!\n" ; + std::cin >> secondnum ; + while ( secondnum.length( ) != firstnum.length( ) ) { + std::cout << "second number string should be as long as the first one!\n" ; + std::cin >> secondnum ; + } + std::vector<std::string> fibonacciWords { firstnum , secondnum } ; + while ( fibonacciWords.back( ).length( ) < 51 ) { + fibonacciWords.push_back( fibonacciWords[ fibonacciWords.size( ) - 2 ] + + fibonacciWords.back( ) ) ; + } + std::cout << fibonacciWords.back( ).substr( 50 , 1 ) << std::endl ; + return 0 ; +} |
